After receiving a JSON response from an API as depicted in the image below: https://i.sstatic.net/5eq43.png
I encountered an issue where the same column_code is used in both the variable_meta
section and the data
part of the response. This column code acts as the variable name for fetching time-series data, leading to confusion on how to obtain the data in this scenario.
I attempted employing the window
method but faced difficulties with its implementation.
In the code snippet provided, my objective is to dynamically replace the utilization of FRWRTM_AirT_2_2_A
with a programmatically generated variable.
if( x[i].FRWRTM_AirT_2_2_A !=-9999) {
d = new Date(x[i].date_UTC)
y.push([d, x[i].FRWRTM_AirT_2_2_A])
//console.log(d, x[i].FRWRTM_AirT_2_2_A)
}
Edit : Including the JSON response requested by some:
{
"meta_data": {
"station_meta": [
{
"city": "xxx",
"station": "yyy",
"lat": 58.992778,
"lon": 15.844722,
"height": 277,
"landcover": "Artificial Surfaces"
}
],
"variable_meta": [
{
"city": "xxx",
"station": "yyy",
"variable": "Air Temperature",
"variable_logger_name": "CS215_AirTemperature_degC_Avg",
"height": 2,
"aggregation": "A",
"level": 2,
"unit": "ºC",
"column_code": "FRWRTM_AirT_2_2_A"
},
{
"city": xxx",
"station": "yyy",
"variable": "Air Temperature",
"variable_logger_name": "CS215_AirTemperature_degC_Min",
"height": 2,
"aggregation": "I",
"level": 2,
"unit": "ºC",
"column_code": "FRWRTM_AirT_2_2_I"
},
{
"city": "xxx",
"station": "yyy",
"varible": "Air Temperature",
"variable_logger_name": "CS215_AirTemperature_degC_Max",
"height": 2,
"aggregation": "X",
"level": 2,
"unit": "ºC",
"column_code": "FRWRTM_AirT_2_2_X"
}
]
},
"data": [
{
"date_UTC": "2018-05-14 11:00:01",
&fracr;FRWRTM_AirT_2_2_A": -9999,
"FRWRTM_AirT_2_2_I": -9999,
"FRWRTM_AirT_2_2_X": -9999
},
{
"date_UTC"::"2018-05-14 12:00:01",,
"FRWRTM_AirT_2_2_A": -9999
"FRWRTM_AirT_2_2_I"": -9999,
"FWRTM_Airt_2_2_x".: -9999
}, ]
}