c# - Parse recursively unknown JSON structure with JSON.NET -


i try parse json structure json.net. properties of first level deserializing correctly.

i have problem deserialize dictionary. object type can anything: string, double, int, bool, list, dictionary , recursively.

example json:

 {      "id":"56d4f8sd4f86ds4f",      "name":"azerty",      "dynprop": {          "xp":100,          "life":100,          "bonus": {              "force": 100,              "defense": 100          },          "ennemies": {              "beast": {                  "wolf": 100,                  "bear": 20              }          }      }  } 

all datas in dynprop node dynamic , can't know object type, depth or anything.

the ouput dynprop object that:

{{"dynprop","{xp:100, life: 100, bonus: {...}, ...}"}} 

in fact, json.net put in object value jobject , not @ inners dictionaries or stuff that.

i try add serialization settings that:

new jsonserializersettings     {         typenamehandling = typenamehandling.all,         typenameassemblyformat = formatterassemblystyle.simple     } 

but no success...

thanks in advance help!

edit: i'm open framework must work on .net 2.0.

i know question explicitly json.net in hopes don't know awesome servicestack library, i'd add recommendation move instead. specifically, servicestack.text namespace has json serializer that's much faster json.net's serializer.

in addition, have jsonobject.parse method handles use case better (i believe). see stack overflow post pretty matches looking for:

servicestack.text.jsonobject.parse vs. newtonsoft.json.linq.jobject.parse nested tree of 'dynamic' instances?


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -