I'm trying to print a single JObject as a CSV row
for example:
{"result": {
"id": "24095",
"hostid": "24094",
"name": "host1.fqdn.com",
"ipaddress" : "192.168.1.184"
}
}
as
id,hostid,name,ipaddress
24095,24094,host1.fqdn.com,192.168.1.184
I can easily iterate through the object with
foreach (var item in jobj) {
Console.Write(item.Key + ",");
}
but I end up with a , at the end of the header
I tried
for (int i = 0; i < jobj.Count; i++)...
but I'm having trouble accessing i.Key. I'm doing something wrong here but i'm not sure what.
Any ideas on how i can print all the keys in an object as a CSV minus a , at the end?
Thank you.