I have a class like these:
class MyDate
{
int year, month, day;
}
I want to fill an object of this class with the data from this JSON string (only from "dateOfBirth"):
{
"firstName":"Markoff",
"lastName":"Chaney",
"dateOfBirth":
{
"year":"1901",
"month":"4",
"day":"30"
}
}
I know the
JsonConvert.DeserializeObject<>(jsonString)
but I am looking for a way to convert only a single object of a whole JsonString into a .Net object.
I am looking for a DeserializeObject method with a JObject as parameter.
3
Answers
you need to parse your json string, only after this you can deserialize any part you need. Your class should be fixed too.
You can use SelectToken
You need to make your class properties to public