问题
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