chuckd
chuckd

Reputation: 14610

Can't fetch json object data

I have this json object that looks like this below but I can't figure out how to acccess the objects data

enter image description here

I want to access the 5th index like this

jsonContent[5] error CS0021: Cannot apply indexing with [] to an expression of type 'object'

Upvotes: 2

Views: 134

Answers (2)

chuckd
chuckd

Reputation: 14610

Here is what is needed, using the JObject library.

var currency = (jsonContent["quotes"] as JObject)["USD"].Value<decimal>();

Upvotes: 0

Jeff R
Jeff R

Reputation: 21

It looks like an object rather than array. So try jsonContent["5"] or jsonContent["[5]"] instead ?

Upvotes: 2

Related Questions