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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -