c# - How to deserialize a nested object? -
c# - How to deserialize a nested object? -
i've managed create deserialization creating info contract class (after nagging on client metric ton). problem both fields i've declared, returning empty stuff. so, i've looked @ , realized json object nested , i'm unclear on how access parts inside.
the info contract i'm getting bopp null (or empty string, not sure which) , mopp bunch of zeros.
[datacontract] public class client { [datamember(name = "beep")] public string bopp; [datamember(name = "meep")] public guid mopp; }
i thought info on form.
[ {"beep":"beep1", "meep":"meep1"}, {"beep":"beep2", "meep":"meep2"}, {"beep":"beep3", "meep":"meep3"} ]
however, apparently, moved object inside other it's more this.
[ "root":[ { "a":"some", "b":[ {"beep":"beep1", "meep":"meep1"}, {"beep":"beep2", "meep":"meep2"}, {"beep":"beep3", "meep":"meep3"}], "c":"some" }, { "a":"some", "b":[ {"beep":"beep1", "meep":"meep1"}, {"beep":"beep2", "meep":"meep2"}, {"beep":"beep3", "meep":"meep3"}], "c":"some" } ]]
how can redesign info contract create access right fields? or missing , name of info fellow member mustn't differ field (i.e. beep , bopp won't work)?!
edit:
as requested, i'm posting (almost) live info string.
{"customerstatuses":[{ "information":[{"guid":"1","role":"customer"}], "customerid":"12345678-1234-1324-1234-123456781234", "status":4}, "information":[{"guid":"5","role":"customer"}], "customerid":"12345678-1234-1324-1234-123456781234", "status":6}, "information":[{"guid":"7","role":"seller"}], "customerid":"12345678-1234-1324-1234-123456781234", "status":6}, ...
and here's actual info contract.
[datacontract] public class client { [datamember(name = "status")] public string status; [datamember(name = "customerid")] public guid guid; }
your class construction needs match json:
<datacontract> public class client <datamember(name:="status")> public property status int32 <datamember> public property info object <datamember> public property customerid string end class public class customers public property customerstatuses list(of customer) end class
c# json serialization
Comments
Post a Comment