Dwight Shrout
Dwight Shrout

Reputation: 65

Working with a string in JSON format

I have a long string in JSON format. This is what it looks like:

{"ShowMapUrl":true,"GameDiffusionType":5,"InputYellowCards":false,"DisplayYellowCards":false,"InputYellowCards2":false}

Note that the string is much longer. I've been trying to convert that string into a dictionary by using json.NET without success. Any tips?

Upvotes: 1

Views: 52

Answers (1)

shf301
shf301

Reputation: 31394

Use JsonConvert.DeserializeObject<Dictionary<string, object>>():

var json = @"{""ShowMapUrl"":true,""GameDiffusionType"":5,""InputYellowCards"":false,""DisplayYellowCards"":false,""InputYellowCards2"":false}";
var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);

Upvotes: 1

Related Questions