My Jobject is as below:
JObject sampleObj = "{
"operator": "AND",
"rules": [
{
"field": "Entity.Country",
"condition": "=",
"value": "'USA'"
},
{
"field": "Entity.ShortName",
"condition": "=",
"value": "'Adele'"
}
]
}"
How do I add another JObject inside the JArray "rules" in the JSON? like below
JObject Parent =
"{
"operator": "AND",
"rules": [{
"field": "Entity.Country",
"condition": "=",
"value": "'USA'"
},
{
"field": "Entity.ShortName",
"condition": "=",
"value": "'Adele'"
},
{
"operator": "AND",
"rules": [{
"field": "Entity.Country",
"condition": "=",
"value": "'USA'"
},
{
"field": "Entity.ShortName",
"condition": "=",
"value": "'Adele'"
}
]
}
]
}"
I tried:
Parent["rules"].Add(sampleObj);
Parent.selectToken("rules").Add(sampleObj);
But, intellisense do not allow me do that. Working on C# + Newtonsoft.Json libraries:
'JToken' does not contain a definition for 'Add' and no accessible extension method 'Add' accepting a first argument of type 'JToken' could be found (are you missing a using directive or an assembly reference?)