Reputation: 2971
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?
Upvotes: 1
Views: 172
Reputation: 35353
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"]);
Upvotes: 2