Here is a JSON array before using JSON.parse:
var temp = {
"queries": [
{
"sample_size": 3,
"results": [
{
"name": "temperature",
"tags": {
"Tag": [
"temperature"
]
},
"values": [
[
1452221580000,
27.5
],
[
1452221640000,
27.1
],
[
1452221700000,
27.3
]
]
]}
]}
}
The goal is to extract a value from the array using JSON.parse().
var jsonparse_temp = JSON.parse(temp);
var dataNum = jsonparse_temp['queries'][0]['sample_size'];
var timestamp1 = jsonparse_temp['queries'][0]['results'][0]['values'][0][0];
var value1 = jsonparse_temp['queries'][0]['results'][0]['values'][0][1];
Next, we check if value1
equals 27.5
.
It's uncertain whether this method correctly assigns the value to the variable.