I have JSON which I need to deserialize, but I don't want to create class with property name.
here's what I get in JSON:
"[{"id":1,"width":100,"sortable":true}, {"id":"Change","width":100,"sortable":true}]"
So how could I do this?
Thanks for advance:)
Answer
You can use JavaScriptSerializer
var list = new JavaScriptSerializer()
.Deserialize>>(json);
var id = list[0]["id"];
Or if you want, Json.Net
var list2 = JsonConvert.DeserializeObject>>(json);
Json.Net also allows you to use dynamic
dynamic list = JsonConvert.DeserializeObject(json);
var wdth = list[0].width;
No comments:
Post a Comment