Need help transforming the following API Response to insert into a table:
ID, MeterID, datetime, reading).
I only need:
- emigId
- readings.importEnergy.value
- readings.ts
JSON just isn't my thing (yet). Everything I try says data not in array or it returns everything. I could alter the table to store everything but given I don't need anything else it seems a waste.
Thanks for any help
{
"emigId": "PV:001111",
"meterSerial": "0007777777",
"type": "PV",
"description": "New PV Generation",
"startDate": "20241006",
"minIntervalS": "1800",
"readings": [
{
"ts:": "2024-10-06T00:00:00.000000Z",
"ts": "2024-10-06T00:00:00.000000Z",
"importEnergy": {
"value": 14773160,
"unit": "Wh"
},
"importActivePower": {
"value": -20,
"unit": "W"
},
"apparentPower": {
"value": 21474836,
"unit": "VA"
},
"currentL1": {
"value": 0.21,
"unit": "A"
},
"currentL2": {
"value": 0.192,
"unit": "A"
},
"currentL3": {
"value": 0.2,
"unit": "A"
},
"mainsFrequency": {
"value": 49.983,
"unit": "Hz"
},
"powerFactor": {
"value": -0.135,
"unit": null
},
"reactivePower": {
"value": 21474836,
"unit": "VAR"
},
"voltageL1L2": {
"value": 426.833,
"unit": "V"
},
"voltageL2L3": {
"value": 428.7,
"unit": "V"
},
"voltageL1L3": {
"value": 427.833,
"unit": "V"
},
"voltageL1N": {
"value": 246.733,
"unit": "V"
},
"voltageL2N": {
"value": 246.867,
"unit": "V"
},
"voltageL3N": {
"value": 247.383,
"unit": "V"
}
},
{
"ts:": "2024-10-06T00:30:00.000000Z",
"ts": "2024-10-06T00:30:00.000000Z",
"importEnergy": {
"value": 14773160,
"unit": "Wh"
},
"importActivePower": {
"value": -20,
"unit": "W"
},
"apparentPower": {
"value": 21474836,
"unit": "VA"
},
"currentL1": {
"value": 0.207,
"unit": "A"
},
"currentL2": {
"value": 0.193,
"unit": "A"
},
"currentL3": {
"value": 0.2,
"unit": "A"
},
"mainsFrequency": {
"value": 49.992,
"unit": "Hz"
},
"powerFactor": {
"value": -0.137,
"unit": null
},
"reactivePower": {
"value": 21474836,
"unit": "VAR"
},
"voltageL1L2": {
"value": 425.167,
"unit": "V"
},
"voltageL2L3": {
"value": 427.167,
"unit": "V"
},
"voltageL1L3": {
"value": 425.65,
"unit": "V"
},
"voltageL1N": {
"value": 245.6,
"unit": "V"
},
"voltageL2N": {
"value": 246.033,
"unit": "V"
},
"voltageL3N": {
"value": 246.283,
"unit": "V"
}
},
],
"startTime": "000000.000000"
}