Im trying to assign a json object to a variable. Im not sure how to accomplish this.
This is my JSON array:
[{“Date”:”2020-01-24 07:35:46″,”sensorName”:”sensor 1″,”sensorValue”:213},{“Date”:”2020-01-24 07:35:46″,”sensorName”:”sensor 1″,”sensorValue”:433},{“Date”:”2020-02-10 06:03:36″,”sensorName”:”sensor 1″,”sensorValue”:321},{“Date”:”2020-02-10 06:03:36″,”sensorName”:”sensor 1″,”sensorValue”:43},{“Date”:”2020-02-12 03:30:57″,”sensorName”:”sensor 1″,”sensorValue”:4321}]
I wish to assign the value of sensorValue to variable yValue. how do i do this?
Below code snippet is in javascript. Cant seem to upload my codes properly.
the brackets for php was replaced with ( instead of <?.
`
var sensor1 = (php echo json_encode($json_sensor1, JSON_NUMERIC_CHECK); );
var sensor2 = (php echo json_encode($json_sensor2, JSON_NUMERIC_CHECK); );
var yValue1 = sensor1.sensorValue;
var yValue2 = sensor2.sensorValue;
var xValue = sensor1.Date;
`