Reputation: 678
I need to deserialize and get child value of a JSON (Jarray) string
string initialJson = File.ReadAllText(Application.StartupPath + "\\Coda.json");
In this case is:
[
"Scan",
[
"4eba277ef42fe2aeb6e3ac17ba00b784",
{
"ID":0,
"Link":"https://www.virustotal.com/file/9416fbb8043d6eb6b544a79e51494a9181c/analysis/1556298405/",
"ScanID":"9416fbb804db12002c39d6eb6b544a79e51494a9181c-1556298405"
}
],
[
"80434f3307d5f66ce3548c6a3c735f34",
{
"ID":1,
"Link":"https://www.virustotal.com/file/63fe7b058c20f39a579a94e56c85638ba7cd6f9f/analysis/1556298411/",
"ScanID":"63fe7b058c20f3524760728294e56c85638ba7cd6f9f-1556298411"
}
]
]
And convert with :
JArray jsonArray = JsonConvert.DeserializeObject<JArray>(initialJson);
After this i start a foreach:
foreach (JObject item in jsonArray.Children<JObject>())
{
foreach (JProperty element in item.Properties())
{
MessageBox.Show(element.Name + " " + element.Value);
}
}
But nothing appear, no messagebox, no error, why?
I need to get the all value or first value and delete it
Upvotes: 2
Views: 1390
Reputation: 1441
JArray inside JArray, than JToken objects:
foreach (JArray item in jsonArray.Children<JArray>())
{
foreach (JToken element in item.Children())
{
foreach(JProperty prop in element){
prop.Value.Dump(prop.Name);
}
}
}
Upvotes: 2