I have a working code:
String objstr = "{\"m_children\":[{\"m_children\":null,\"m_name\":\"child0\"},{\"m_children\":null,\"m_name\":\"child1\"}],\"m_name\":\"Root\"}"; byte[] byteArr = Encoding.ASCII.GetBytes(objstr); MemoryStream ms = new MemoryStream(byteArr); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Node)); Node obj = (Node)ser.ReadObject(ms);
What bothers me is that I need to know the type of object contained in the string before decrypting it. I wanted to send an object encoded in JSON through a TCP channel, and should not send additional information about what type of object it has.
source share