Could you please help, I do not know how to get to data after opening JSON file in Matlab. When its open I get data in form of 3x1 cell containing 3 times 1x1 struct with also 19x1 struct data field and columns in first struct field: "data_time" "tooltip_value" "value"
part of JSON:
"data":[{"date_time":1597968882000,"tooltip_value":0.20513,"value":0.2051274641463},{"date_time":1598050973000,"tooltip_value":0.24814,"value":0.2481352158793},{"date_time":1598134408000,"tooltip_value":0.21524,"value":0.21524491588220002},{"date_time":1598405314000,"tooltip_value":0.21476,"value":0.2147630998212},{"date_time":1598549286000,"tooltip_value":0.19774,"value":0.1977396932195},{"date_time":1599127692000,"tooltip_value":0.22473,"value":0.22473225745569997},{"date_time":1600369794000,"tooltip_value":0.20077,"value":0.2007681102187},{"date_time":1601032111000,"tooltip_value":0.23335,"value":0.23335248258320002},{"date_time":1601198471000,"tooltip_value":0.22807,"value":0.22806941674040002},{"date_time":1601445642000,"tooltip_value":0.23584,"value":0.23584042110120002},{"date_time":1601620790000,"tooltip_value":0.21265,"value":0.21265419035879998},{"date_time":1601777380000,"tooltip_value":0.25022,"value":0.2502199889207},{"date_time":1601942767000,"tooltip_value":0.21143,"valu e":0.2114320344667},{"date_time":1602025213000,"tooltip_value":0.23081,"value":0.2308069067011},{"date_time":1602108652000,"tooltip_value":0.21114,"value":0.21114077299169998},{"date_time":1603184498000,"tooltip_value":0.21554,"value":0.2155385588332},{"date_time":1603350002000,"tooltip_value":0.2293,"value":0.229302053873},{"date_time":1603515737000,"tooltip_value":0.21503,"value":0.2150290288937},{"date_time":1603602042000,"tooltip_value":0.22225,"value":0.222248220073}],
To convert JSON into a Matlab structure use jsondecode
.
s = '{"data":[{"date_time":1597968882000,"tooltip_value":0.20513,"value":0.2051274641463},{"date_time":1598050973000,"tooltip_value":0.24814,"value":0.2481352158793},{"date_time":1598134408000,"tooltip_value":0.21524,"value":0.21524491588220002}]}';
S = jsondecode(s);
Given part of your string, the result is a 1x1
structure S
containing a 3x1 structure data
.
To access the structure use dot indexing in the following way.
S.data(2).date_time
If part of your structure is a cell array, index it with {}
brackets. Following your description this would be implemented like this.
S{3}.data(2).date_time
For futher reference I recommend reading struct documentation and cell array documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.