0
I have a json input as follows, need to replace the machine key with it’s name and then need to have following output json with the required mapping.
distance – “code” : “X2-P1”
temp – “code” : “X1-P1”
weight – “code” : “weight”
Need to change the values into string for some codes. Could someone help on this.
Input JSON
[
[
{
"id": 26359,
"name": "station green"
},
{
"id": 22321,
"name": "ravenstein"
}
],
[
{
"time": "2024-06-16T21:30:40.289705Z",
"machine": 22321,
"temp": 18,
"distance": 0.113,
"long": 0.7866,
"weight": 0.2563
},
{
"time": "2024-06-16T19:02:16.970647Z",
"machine": 26359,
"temp": 27,
"distance": 0.453,
"site": 2219,
"weight": 7.0261
}
]
]
Output JSON
[
{
"stationname": "ravenstein",
"Date": "2024-06-16 21:30:40",
"data": [
{
"value": "0.113",
"code": "X2-P1"
},
{
"value": "18.0",
"code": "X1-P1"
},
{
"value": 0.2563,
"code": "weight"
}
]
},
{
"stationname": "station green",
"Date": "2024-06-16 19:02:16",
"data": [
{
"value": "0.453",
"code": "X2-P1"
},
{
"value": "27.0",
"code": "X1-P1"
},
{
"value": 7.0261,
"code": "weight"
}
]
}
]
Thank you.