-4

I have a JSON string as below.

{"checkbox-1026":"eba8786c-f31d-4c5a-92ce-2d8ffd7c1066","checkbox-1027":"1b529116-1c58-4ac5-ad9d-04bd0d296335"}

I need to get values "eba8786c-f31d-4c5a-92ce-2d8ffd7c1066" and "1b529116-1c58-4ac5-ad9d-04bd0d296335".

Can anyone help me to get the values?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 2
    [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/) should be your solution. – Jerodev Dec 11 '17 at 12:03
  • 2
    What did you try? – EvZ Dec 11 '17 at 12:04
  • there are plenty of examples at [Json.net](https://www.newtonsoft.com/json) – styx Dec 11 '17 at 12:05
  • Will the json string always have the same keys? – Jerodev Dec 11 '17 at 12:06
  • use JSON.NET and JsonConvert.DeserializeObject<> – Niladri Dec 11 '17 at 12:13
  • I have tried the above possible solutions but not working. It is not static, it is just example data which I get from CheckBoxGroup checked values in controller in ext.net mvc. It is not exactly in json format. So please check the data and help me for possible solution. Thank you. – user2901906 Dec 12 '17 at 01:47
  • See [How can I parse a JSON string that would cause illegal C# identifiers?](https://stackoverflow.com/q/24536533/10263) – Brian Rogers Jan 08 '18 at 15:59

1 Answers1

1

Try with Newtonsoft.JSON. Sample below shows how to get those values

var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(j1);
foreach (var kvp in dict)
{
    Console.WriteLine(kvp.Value);
}

Here is working demo link https://dotnetfiddle.net/MGkRIA

Cinchoo
  • 6,088
  • 2
  • 19
  • 34
  • Can you please check my key value pairs? In order to use JsonConvert.DeserializeObject, you need to have same values in key string. But in my case the key string values are also different. – user2901906 Jan 10 '18 at 04:26