Reputation: 3410
I have the following JSOn I need to parse:
{"items":[{"dict":"es","words":[{"word":"car","id":"3487"},{"word":"dog","id":"443"},{"word":"plane","id":"1171"}]},{"dict":"fr","words":[{"word":"house","id":"134"}]}]}
Using JavaScriptSerializer, how could I iterate first through each dict and then retrieve the id of each word?
Upvotes: 1
Views: 99
Reputation: 656
make anonymouse type, acording your json, for example:
var result = new[] {new {action = "", value = false}}; // put your item structure here
var list = JsonConvert.DeserializeObject(myJson, result.GetType());
then you might want to itterate through. For example:
foreach (dynamic val in ((dynamic) list)) { ...
Upvotes: 1