Need help parsing JSON in JavaScript

Hello I am new to JS ant REST API so I have a question, because I am stuck.
I use postman to send GET request from server where I keep vehicle location data etc.
The response is the JSON file full of vehicle location history. I see that data is gathered in array called Positions, but every position is as object. What I need is map every position in Javascript array or some kind of list so I could read my data, when the vehicle was moving, when not. Please help, or at least tell me what is the most efficient way for gathering everything… I am attaching portion of JSON:


Your data is just there, as written. If you run JSON.parse(theJsonTextStringYouWantToParse) it’ll parse from string -> object. Mapping that array is trivial, but can you explain what data looks like coming in and out, and what you’re doing with it (what value states whether the vehicle is moving or not, how do you envisage the output array looking, and how is it more useful than an array of points of detailed information under named keys, which is what you have now?), it’s easier to provide useful advice if that is known

I give the server the vehicle license plate num., the date from and date to, and the server gives me event list with 1000+ objects like this :

The parameters: Ignition shows if the car engine is started,
State shows if it is moving.

What I want to know when was the vehicle Ignition true, but vehicle is not moving because events are timed automatically every 10 seconds, so I need to know how long the vehicle was ON ignition but NOT moving.

So ignition true and speed 0?

So filter on the array will give you a filtered array of objects first of all.

Then how do you calculate time for that? How long between data points? Is it consistent?

Critically, does the time need to take into account time from when speed was 0 to not 0 (ie you need to include the next data point as well even if speed is non-zero) – this kinda precludes using filter (you can do it, but logic becomes a little convoluted, is probably easier to use a loop)

Speed is not that important, the parameter State shows if the vehicle is moving or not. Events are timed by 10 second intervals so time when vehicle is not moving would be calculated from first interval which has State - “Stopped”, till when the State changes to “Moving”. Also data doesn’t need to be very precise, I know that some time can be lost in from one interval to another, but that’s not important.
So how I think of calculating is every Positions array element which has Ignition ON, State “Stopped” from when the Time is earliest till the State changes to “Moving”.CaptureCodeCamp

Still same question though: what do you want the data to look like after you have manipulated it? You are picking data points between dates: you can caclulate see how long a vehicle was moving vs not moving, but how you want that data structured is critical to being able to program the transformation from what you have now to the end result.

The reason I asked re including the next point is that

Could be the first point after one where speed is zero, or it could just be when speed is zero: this makes a significant difference programming-wise as to how you approach things and is important to clarify.