I have a JSON data structure that looks like this:
[{"id": "ARMpalmerillas07", "type": "GreenHouse","act_OpenVentanaCen": {"type": "float", "value": 0, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}},
"act_OpenVentanaLatNS": {"type": "float", "value": 0, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}},
"act_Aerotherm": {"type": "float", "value": 0, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}},
"act_BombaCalefaccion": {"type": "float", "value": 0, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}},
"var_ValvulaPpnalCalefaccion": {"type": "float", "value": 0, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}},
"var_VoltSensorTempSuelo3": {"type": "float", "value": 3, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}}}]
Currently, I am unsure of how to work with this data. Specifically, I would like to extract the value stored in
var_ValvulaPpnalCalefaccion.value
In my code, I am utilizing the .map(res => res.json());
method in both the component and the service.
public datos: any = [];
this.datos = response;
console.log('Showing the headers:' + JSON.stringify(this.datos));
How can I correctly assign these values?
At the moment, I am attempting this:
public Tempext: ContextBrokerModels;
Model Definition:
export class ContextBrokerModels {
builder(
public type: string,
public value: string
) {}
}
this.Tempext = response[0].var_ValvulaPpnalCalefaccion.value;
Is this approach correct?