0

I've had a look at the existing answers on this, but it's not really helping me... :) I'm trying to access the file;

{   "user":{
    "name":"something",
    "sessionid":"local"   },   "stats-change":[
    {"1000":1},
    {"1004":1},
    {"2000":5997},
    {"1001":1},
    {"1100":821},
    {"2020":10},
    {"2010":3},
    {"2023":1},
    {"5242880":1},
    {"16777253":4}   ],   "checksum":"3f3c02b018c90c56793623c854ffbb64" }

I want to iterate through the stats-change elements, I've got;

Dictionary<string, dynamic> values = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(_StatsFile);

which allows me to isolate stats-change, but I can't seem to case the dynamic back to a dictionary so I can use the keys, values of the stats change bit..

I'm sure this is simple, but it's eluding me.

1 Answer 1

1

You can't cast the stats-change entry itself to a Dictionary, because it is not one. It is an array. You will have to treat it as an array, and then cast each element in that array to a Dictionary.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there any easy way to change it into a string array?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.