c# - Deserializing a child into an object -
i've tried examples on here tearing hair out.
i query , returns json, inside json lots of hashes, eg.
{ "gjwiegjeigj": { ....}, "gjeeigjwoeigj": {...} ... }
i want loop through each of these, , deserialize contents object.
i've created object, myobject has fields, stuck on deserialising.
i can deserialise straight base object using jsonconvert.deserializeobject
can't that, need loop through , children.
i want array of custom objects fields taken json result of this, don't care title of each 1 (the garbage hash).
any ideas? know can loop through, gives me lots of jtokens that's stuck.
edit: reading question again, mention both knowing , not knowing fields. sounds don't know fields json string contain.
for cases this, suggest use dynamic
-- shines. if know field names, class should deserializing without issue.
what have tried? show real code, , real exceptions or problems.
to deserialize list of dynamic objects simple:
dynamic toreturn = jsonconvert.deserializeobject<list<dynamic>>(rawjson);
you should list of dynamic objects. can poke fields want:
console.writeline(toreturn.first().gjwiegjeigj);
Comments
Post a Comment