Reputation: 33
I am getting a response from a API that returns the following json:
[
{
"input_index":0,
"candidate_index":0,
"components":,
{
"child1":"sam",
"child2":"tom",
}
}
]
i need to get the results of child1 and child2 using c# and json.net.
Upvotes: 0
Views: 12446
Reputation: 12577
It should be fairly straightforward. Just parse the JSON, then get the child items from the components
object of the array's first index:
var obj = JArray.Parse(json);
string child1 = (string)obj[0]["components"]["child1"];
string child2 = (string)obj[0]["components"]["child2"];
Upvotes: 5