json.NET parsing issue with twitter API data

ε祈祈猫儿з 提交于 2019-12-04 07:35:34

I was getting the exact same error and eventually figured it out. Instead of using JObject.Parse use JArray.Parse. So here is your code:

string sCmdStr = String.Format("https://api.twitter.com/1/users/lookup.json?screen_name={0}", sParam);
string strJson = _oauth.APIWebRequest("GET", sCmdStr, null);
JArray jsonDat = JArray.Parse(strJson);

You can then loop through the array and create a jobject for each individual tweet.

for(int x = 0; x < jsonDat.Count(); x++)
{
     JObject tweet = JObject.Parse(jsonDat[x].toString());
     string tweettext = tweet["text"].toString();
     //whatever else you want to look up
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!