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.
Answer
You can create object-wrapper and put data type identificator to the first field of this wrapper.
No comments:
Post a Comment