I am trying to deserialize this json using C#:
{"query":
{"count":10,"created":"2011-06-18T19:15:24Z","lang":"en-US","results":
{"Result":[{"id":"21373494","Title":"Sushi Bistro","Address":"455 Balboa St","Rating":
{"AverageRating":"5"}
}
{"Result":[{"id":"21373495","Title":"Sushi Bistro","Address":"4565 Balboa St","Rating":
{"AverageRating":"1"}
}
}
}
I tried Newton json.NET, then used JSONHelper class, but it didn't work. Could someone provide a short sample how to deserialize to the object and loop through 'Result' in C#?
UPDATE: sorry for invalid json, ouput is crazy big, so I tried to copy just a small part. However you can see a pattern of Result set in here.
Json provided above is invalid, try to fix json first and after this i guess your code will work.
You can use jsonlint service to validate json.
Example of deserializing json from string using newton json dll:
var json = "..";
string output = JsonConvert.DeserializeObject<MyClass>(json);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.