从网址获取价值(字符串)Api [英] Get Value(string) Api From Url
问题描述
我有以下网址:
http://data.mtgox.com/ api / 1 / BTCUSD /自动收报机 [ ^ ]
我使用下面的代码:
I Have URL Like:
http://data.mtgox.com/api/1/BTCUSD/ticker[^]
while i used the like below:
public void getValues()
{
HttpWebRequest request = WebRequest.Create("http://data.mtgox.com/api/1/BTCUSD/ticker") as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string s = reader.ReadToEnd().ToString();
Response.Write(s);
}
}
使用Above功能有一段时间我遇到问题
[操作有超时]或[未找到远程服务器]
------------------------ -------------------------------------------------- ----------------------
并在[http://data.mtgox.com/api/1/BTCUSD/ticker [ ^ ]] url帮帮我。
如果有任何其他方法然后建议
需要它的朋友
With Above function some time i get the problem
[The operation has timed out] or [remote server not found]
------------------------------------------------------------------------------------------------
and with help of [http://data.mtgox.com/api/1/BTCUSD/ticker[^]] url help me out.
if any other method then suggest
need it friends
推荐答案
你有一个JSON字符串。您可以按照本文阅读: http://aspdotnet.hotinit.com /2012/01/get-json-data-from-url.html [ ^ ]并且您必须选择如何处理字符串。我建议你参考以下文章来比较JSON库: fastJSON [ ^ ] - 当然,这是一个很好的用于反序列化。如果您已将其反序列化为对象集合,则可以使用linq查询它。这也是一种有趣的方法: http://james.newtonking.com /projects/json/help/index.html?topic=html/LINQtoJSON.htm [ ^ ]
You have a JSON string there. You can follow this article to read it: http://aspdotnet.hotinit.com/2012/01/get-json-data-from-url.html[^] and than you have to choose how to process the string. I suggest you consult following article for a comparison of JSON libraries: fastJSON[^] - and of course, a good one to use for deserialization. If you have deserialized it to a collection of objects, you can simply query that with linq. This is also one interesting approach: http://james.newtonking.com/projects/json/help/index.html?topic=html/LINQtoJSON.htm[^]
这篇关于从网址获取价值(字符串)Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!