Deserializing nested json object c# -


this question exact duplicate of:

i have nested json object, this,

  "where": {       "operator": "and",       "left": {         "operator": "=",         "$fieldref": "requestor",         "value": "@me"       },       "right": {         "operator": "=",         "$fieldref": "state",         "value": "closed"       }     }, 

i deserialize in c#, problem object can more larger depending on user, object can follows,

and this,

"where": {       "operator": "or",       "left": {         "operator": "startswith",         "$fieldref": "id"       },       "right": {         "operator": "or",         "left": {           "operator": "startswith",           "$fieldref": "orgid"         },         "right": {           "operator": "and",           "left": {             "operator": "startswith",             "$fieldref": "firstname"           },           "right": {             "operator": "startswith",             "$fieldref": "lastname"           }         }       }     }, 

please consider using popular library this: json.net

then can use built in visual studio parse tool json classes found found under: edit -> paste special -> paste json classes. generate classes needed json.

once you've added reference json.net can run following deserialize:

rootobject deserialized = jsonconvert.deserializeobject<rootobject>(jsonstring); 

were "rootobject" top class json structure.


Comments