Would like some help in parsing the JSON and insert (or at least output the key value pairs) without a specific class/object.
JSON string (portion):
{
"message": "Success",
"data": {
"100": {
"Type": "Solid",
"Name": "Sphere",
},
"101": {
"Type": "Solid",
"Name": "Cube",
},
"102": {
"Type": "Solid",
"Name": "Cylinder",
}
},
"Error": []
}
I want to be able to get value like:
| ID | Type |Name |
| 100|Solid|| Sphere|
| 102|Solid || Cube |
| 103|Solid || Cylinder|
var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var jObject = JObject.Parse(json);
var flattened = jObject.Flatten();
foreach (var item in flattened)
{
Console.WriteLine(item.Key + " ### " + item.Value);
}
var flattenedJsonString = JsonConvert.SerializeObject(flattened, Formatting.Indented);
Console.WriteLine(flattenedJsonString);``
But I am not getting clean values as I desire. Any help? Thanks.
1