I am attempting to parse a JSON string and extract the array values within it.
{"_search":true,"nd":1492064211841,"rows":30,"page":1,"sidx":"","sord":"asc","filters":"{\"groupOp\":\"OR\",\"rules\":[{\"field\":\"Emp_ID\",\"op\":\"cn\",\"data\":\"ASAS\"},{\"field\":\"Name\",\"op\":\"cn\",\"data\":\"ASAS\"},{\"field\":\"Designation\",\"op\":\"cn\",\"data\":\"ASAS\"},{\"field\":\"City\",\"op\":\"cn\",\"data\":\"ASAS\"},{\"field\":\"State\",\"op\":\"cn\",\"data\":\"ASAS\"},{\"field\":\"Country\",\"op\":\"cn\",\"data\":\"ASAS\"}]}"}
PS: The string above is being passed from jqGrid Ajax to the WebMethod in C#.
I am facing challenges in extracting the value of filters->rules[0]->data.
What I have attempted :
dynamic jObj = JObject.Parse(postData);
var data = jObj.filters.rules[0].data;
Error received: 'Newtonsoft.Json.Linq.JValue' does not contain a definition for 'rules'.
dynamic jObj = JObject.Parse(postData);
var filters = jObj.filters; //Successful: able to retrieve filters here
var rules1 = filters["rules"]; //Error: 'Newtonsoft.Json.Linq.JValue' does not contain a definition for 'rules'.
var rules2 = filters.rules; //Error: 'Newtonsoft.Json.Linq.JValue' does not contain a definition for 'rules'.
How can I access the value within filters->rules AND filters->rules[0]->data ?