StackOverflowの検索APIを使用して質問を検索しようとしています。
私はこのアクションを使用して解析を実行しています:
public ActionResult StackExchange(string sq)
{
string url = "http://api.stackoverflow.com/1.1/search?intitle=" + sq + "&order=desc";
var client = new WebClient();
var response = client.DownloadString(new Uri(url));
JObject o = JObject.Parse(response);// ERROR
int total = (int)o["total"];
return View(total);
}
これが私が解析しようとしているJSONURLです:
http://api.stackoverflow.com/1.1/search?intitle=asp.net%20custom%20404&order=desc
次のデータを抽出しようとしています。
`"total": 3` ,
`"question_timeline_url": "/questions/10868557/timeline",`
`"title": "Asp.net custom 404 not working using Intelligencia rewriter"`
次のようなエラーが発生します:Newtonsoft.Json.JsonReaderException:値の解析中に予期しない文字が検出されました:。パス''、行0、位置0。
例外の理由は何でしょうか?以前に同じ方法を使用しましたが、問題なく機能しました。
提案してください。