Reputation: 1417
I have the following json parsed into a JObject
:
JObject json = JObject.Parse(@"{
""event"": {
""name"": ""daniel""
},
""markets"": [
{}
]
}");
With that JObject
I'm trying to retrieve the empty JObject
that's in the markets
JArray
.
I'm currently trying json.SelectToken("$.event.markets[0]")
but that's not working, it returns null
rather than the empty JObject
that I expect.
Is there a way to get that empty JObject
by using the SelectToken
|| SelectTokens
method? I'd prefer to stay away from using linq, but if I must I must.
Upvotes: 1
Views: 654
Reputation: 1746
This should be json.SelectToken("$.markets[0]")
instead of json.SelectToken("$.event.markets[0]")
as markets is not contained within the event object.
Upvotes: 2