1

I have the below JSON

[{"name":"sEcho","value":3},{"name":"iColumns","value":7}]

When i deserialize using JOSN.NET i ll get o/p as List of name and values

name sEcho
value 3

Is it possible somehow to get like

sEcho 3
IColumn 7

This is the string am getting from JQUERY DataTable to my controller and am trying to convert into a class using Newton soft .

How do i achieve this?

1 Answer 1

2

You can convert it to dictionary

string json = @"[{""name"":""sEcho"",""value"":3},{""name"":""iColumns"",""value"":7}]";

var dict = JArray.Parse(json)
           .ToDictionary(x => (string)x["name"], x => (string)x["value"]);

Console.WriteLine(dict["sEcho"]);
Sign up to request clarification or add additional context in comments.

Comments

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.