c# - Deserialize json with Json.NET -
i have json looks (from philips hue api):
{ "1": {"name": "bedroom"}, "2": {"name": "kitchen"} }
when try deserialize document run problems because document structured way is.
if had been formated this:
[ {"nr": "1", "name": "bedroom"}, {"nr": "2", "name": "kitchen"} ]
everything have been fine. forced string parsing in order extract data... :-(
any ideas or suggestions?
i deserialize jobject
, use dictionary
var jobj = (jobject)jsonconvert.deserializeobject(json); console.writeline(jobj["1"]["name"]);
or
dynamic jobj = jsonconvert.deserializeobject(json); console.writeline(jobj["1"].name);
Comments
Post a Comment