1

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?

1
  • 1
    Json is not a format. It is serialized object data. You cant deserialzie part of a json string, so you should post it all as well as how you are trying to use it. Commented Jan 24, 2016 at 0:52

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

2 Comments

It works with the string you used, but not with mine. But why do you have more quotes than I do? What does the symbol @ do?
@DwightShrout - 2.4.4.5 String literals.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.