This project has moved and is read-only. For the latest updates, please go here.


May 5, 2009 at 7:31 PM
I am new to and I fancy your work!
I am trying to use the DeserializeObject method in order to convert a json into an object similar to the following example:

string json = "{'action' : 'actoin name','data' : {'data property' : 'data property value'}}";
Request req = JsonConvert.DeserializeObject<Request>(json);

my Request object contains 2 members: action and data wheras data is another json object should be DeserializeObject accordign to the action property
I thought that one solution would be that the data memebr would be from type of string and I would be able to Deserialize later.
Can you please suggest how can it be done?
May 6, 2009 at 10:58 AM
Load it into a JObject, take a look at the value of action and then create a reader from the data value and pass it to the JsonSerializer with what type you want it to be.