C# – Convert JSON string to Dictionary in c#

asp.netc++json

I have a json string like

{
    "action":"postRecord", 
     "data":{
            "0":{
                  "lid":999,
                   "cid":1234
                 },
            "1":{
                  "lid":111,
                  "cid":"6789"
                 }
        }
}

and

i want it co convert to Dictionary object so that i can get the data and iterate over it like
data[0][lid] = 999
data[0][cid] =1234
data[1][lid] = 111
data[1][cid] = 6789

The problem is that i have to use ONLY Native Libraries of .net and I have version 2.0

Best Solution

You can do

Dictionary<string, object> obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(Convert.ToString(data));

using JSON.NET