my project gets lot of json strings via udp, each string describing list of objects. could'nt write function list, , make derialization list. problem can not make derialization without knowing class name of objects make list. tried give each department id field .. here, too, not derialization specific field, because department name not known.
does have solution?
yes, json problem. go way of encapsulation. firstly create wrapper:
public class jsonobjectwrapper { public string objecttype; public string objectinjson; [donotserialize] // sorry not remember attribute exclude serialization public object objectdata; } during serialization explicitly serialize objectdata objectinjson. , send serialized jsonobjectwrapper.
on incoming side know jsonobjectwrapper. deserialize - json object , object type. find object type, create using factory , deserialize objectinjson objectdata.
the procedure above work if may wrapping on transmitting side. otherwise, screwed :-)
Comments
Post a Comment