calculating total retweets TO a user by JSON Parsing

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 05:53:56

问题


I am calculating total number of retweets in C#,My Idea is to calulate the retweeted_status field in the JSON response.I am using JSON.NET.Is there any shorter way to calculate it? Other way would be to create the classes and populate the Response and iterate theough the object.But I am looking for a shorter way because Its just a simple count. Any one who can help me, This is JSON response


回答1:


Yes, you do this by deserilaize the json into a dynamic object using Json.Net.

dynamic values = JsonConvert.DeserializeObject<dynamic>(json);

and to iterate the values just cast it to Dictionary<string, object>

IDictionary<string, object> list = (IDictionary<string, object>)values;


来源:https://stackoverflow.com/questions/11373482/calculating-total-retweets-to-a-user-by-json-parsing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!