I am getting JSON objects through http requests and I was wondering if there is a way to access, via Newtonsoft
to child properties of an object directly.
This is an example of the JSON I receive:
{
"id": "005",
"name": "John",
"job":
{
"id":"110",
"name":"developer",
}
}
And I would like to get just the job id without mapping the whole object into a class.
[JsonProperty("id")]
public string id { get; set; }
[JsonProperty("name")]
public string Name {get; set; }
[JsonProperty("job.id")] //Doesn't seems to work, heh :)
public string JobId { get; set; }
Is there a simple way to do something like this without making a new class neither add extra logic to the code?
I'm looking for a way that allows me to do it directly in the constructor, so that later I can deserialize it to an object in the following way:
var myObject = JsonConvert.DeserializeObject<MyObject>(response);