S
S
shpeks2019-12-02 20:42:29
JavaScript
shpeks, 2019-12-02 20:42:29

How to parse json array of objects using js?

There is this json file:

[{"NumberStop":26,"NumberBus":9,"AvgCountPassengers":5,"DayOfWeek":1},{"NumberStop":90,"NumberBus":9,"AvgCountPassengers":5,"DayOfWeek":1},{"NumberStop":27,"NumberBus":9,"AvgCountPassengers":5,"DayOfWeek":1},{"NumberStop":77,"NumberBus":9,"AvgCountPassengers":6,"DayOfWeek":1},{"NumberStop":14,"NumberBus":9,"AvgCountPassengers":3,"DayOfWeek":1},{"NumberStop":15,"NumberBus":9,"AvgCountPassengers":6,"DayOfWeek":1},{"NumberStop":44,"NumberBus":9,"AvgCountPassengers":5,"DayOfWeek":1},{"NumberStop":8,"NumberBus":9,"AvgCountPassengers":8,"DayOfWeek":1},{"NumberStop":89,"NumberBus":9,"AvgCountPassengers":11,"DayOfWeek":1},{"NumberStop":25,"NumberBus":9,"AvgCountPassengers":2,"DayOfWeek":1}]

How to turn it into an object from which you can then take data?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Babintsev, 2019-12-02
@shpeks

const data = JSON.parse('твоя json строка');
Now your object is inside the constant data.

A
Alexander, 2019-12-02
@NeiroNx

If you use JQuery, then it is automatically parsed there and returns an array of objects.
about another way here: https://habr.com/ru/post/252941/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question