-2

I have a json string like below :

{ "error" : "xxxx" , "data" : int type or {...other complex json object} }

I don't know when return int or other json string from data field , and how to deserialize this ?

when type of data is object or dynamic , the real deserialized type of data is int or Dictionary using JavaScriptSerializer.Deserialize(string json).

the real deserialized type of data is Int64 or JContainer when using Json.Net.

is there a elegance way to solve this ? I don't think reflection is a good way.

Simon
  • 1
  • 2
  • have a look at this post please: http://stackoverflow.com/questions/9145667/how-to-post-json-to-the-server/10027534#10027534 Here is the library I mention in this post, I wrote it to help me deserialize/serialize json requests/responses. https://github.com/ademargomes/JsonRequest – Ademar May 15 '13 at 15:29

1 Answers1

1

You can create object-wrapper and put data type identificator to the first field of this wrapper.

Phantom
  • 1,704
  • 4
  • 17
  • 32