Reputation: 11
I have data from a file that is arranged like so:
[{"start": "2014-02-24T00:48:57", "stop": "2014-02-24T07:30:53", "events": [[60.0, 1, 0.015800000000000002],...,[28500.0, 3,
0.034299999999999997]]}]
where the '...' symbolizes repeating data in the form [x, y, z]
separated by commas
x appears to be a float; y is always 1, 2, or 3; z appears to be a double
The data is a .txt file and all this data is contained on one line. I am getting this data from a third party source so I cannot get it in any other format.
I want to be able to read the start and stop sections separately, and then read all of the events section into arrays.
Ex. x = 60.0 ... 28500.0; y = 1 ... 3; z = 0.015800000000000002 ... 0.034299999999999997
I have an idea on how to read the first sections, but I'm not sure on how to handle the brackets, and braces.
I imagine I could read in 3 values: start
, stop
, and events
and then parse events from there. But I still am a bit confused. I am not looking for an exact answer necessarily, just how to go about doing it.
This data is obtained from the SleepCycle
app I use on an iPhone
.
Upvotes: 1
Views: 83
Reputation: 26
Parse it as JSON => you now have an array with a single element in it. That element is an object with start, stop, and events attributes.
I think the specifics depend mostly on what language you're using and what json parsing libraries are available.
Upvotes: 1