I have a JSON string as shown below. I want to remove the empty array objects from it programmatically so that I can convert it to a DataTable
.
Here is an example of my JSON:
{
"result":[
{
"id":"1",
"name": "Temp",
"property":[]
},
{
"id":"2",
"name": "Temp2",
"property":[]
}
]
}
You can see that the property
member in each result is an empty array. Any suggestion on how I can remove it?
Currently I'm doing the following to convert the JSON to a DataTable
:
DataTable dt = JsonConvert.DeserializeObject<DataTable>(data["result"].ToString());
When I manually remove the array property, the conversion works perfectly.