Json parsing and looping

I have deserialized a json array successfully and i am able to pull out certain value using an index at an instance e.g [1],[0], however i am struggling to use an index variable and get that information out in a loop


when i replaced the number this index it gave a parsing error

1 Like

Hey,
try to use concatenation. Something like this:
parsedJson.SelectToken(“outputValues.json-output[” + i.ToString + “.tax”).ToString

Hey Piotr,
it gave a similar error as before "Unexpected character while parsing path indexer: .

Hi @Ismail_Naous, can you share the error screenshot.

Try below
parsedJson.SelectToken("outputValues.json-output[" + i.ToString()+ "].tax").ToString()

Regards,
Arivu

same error :frowning:

looks like missing closing ]
parsedJson.SelectToken("YourPropertyName[" + i.ToString + "].tax").ToString

1 Like

That’s right. When I wrote expression, I missed closing “]

¯_(ツ)_/¯

parsedJson.SelectToken(“outputValues.json-output[” + i.ToString + “].tax”).ToString

2 Likes

Yes, this works now ! Thank you Piotr !

I was looking for this. It works.
Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.