I am trying to convert the below JSON file to CSV (data frame) using jsonlite package in R. I am not able to do so. I am looking for a generic method that could parse JSON of any complexity and nesting?
library(jsonlite)
fromJSON(json_file)
JSON file:
{
"IRD": {
"INTV": {
"INTVStatus": "SERV_HST",
"RD": {
"U": "kWh",
"BEV": "0.0379",
"Val": "0",
"RV": "0",
"port": "1"
},
"RD": {
"U": "kWh",
"BEV": "0.0379",
"Val": "0",
"RV": "0",
"port": "2"
},
"RD": {
"U": "Vrms",
"BEV": "231.0000",
"Val": "231.0000",
"RV": "231",
"port": "3"
},
".attrs": {
"GatewayCollectedTime": "2015-12-21T12:05:02.257-05:00",
"INTVSequenceNumber": "47112",
"BlockSequenceNumber": "0",
"EndTime": "2015-12-21T10:00:00.000-05:00"
}
},
"INTV": {
"INTVStatus": "SERV_HST",
"RD": {
"U": "kWh",
"BEV": "0.0379",
"Val": "0",
"RV": "0",
"port": "1"
},
"RD": {
"U": "kWh",
"BEV": "0.0379",
"Val": "0",
"RV": "0",
"port": "2"
},
"RD": {
"U": "Vrms",
"BEV": "231.0000",
"Val": "231.0000",
"RV": "231",
"port": "3"
},
".attrs": {
"GatewayCollectedTime": "2015-12-21T12:05:02.257-05:00",
"INTVSequenceNumber": "47113",
"BlockSequenceNumber": "0",
"EndTime": "2015-12-21T11:00:00.000-05:00"
}
},
"INTV": {
"INTVStatus": "SERV_HST",
"RD": {
"U": "kWh",
"BEV": "0.0379",
"Val": "0",
"RV": "0",
"port": "1"
},
"RD": {
"U": "kWh",
"BEV": "0.0379",
"Val": "0",
"RV": "0",
"port": "2"
},
"RD": {
"U": "Vrms",
"BEV": "231.0000",
"Val": "231.0000",
"RV": "231",
"port": "3"
},
".attrs": {
"GatewayCollectedTime": "2015-12-21T12:05:02.257-05:00",
"INTVSequenceNumber": "47114",
"BlockSequenceNumber": "0",
"EndTime": "2015-12- 21T12:00:00.000-05:00"
}
},
".attrs": {
"NumberINTVs": "3",
"EndTime": "2015-12-21T12:00:00.000-05:00",
"StartTime": "2015- 12-21T09:00:00.000-05:00",
"INTVLength": "60"
}
},
".attrs": {
"Version": "2.0",
"DocumentID": "aebjjjjd-59de-4405-ac0b-50e33b0b4f4b-1",
"JobID": "3354",
"ExportID": "aeb5bf7d-59de-4405-er0b-50e33b0b4f4b",
"RunID": "20430452",
"CreationTime": "2015-12-21T13:55:00.807-05:00",
"StartTime": "2015-12-21T09:55:00.000- 05:00",
"EndTime": "2015-12-21T13:55:00.000-05:00"
}
}
JSONdoesn't have an obvious tabular equivalent, at least without some decisions being made.