A
A
Alexander Yudaev2014-08-29 12:35:17
JavaScript
Alexander Yudaev, 2014-08-29 12:35:17

What is the best way to process JSON data with JS?

Good day,
Please advise a ready-made script or a good guide, just do not send Json, jQuery, etc. to sites. I

started working with a project in which I receive API in JSON format (such formats are [{..}], {.. .}, [{..}{..}], {[...]}).
I looked all over the Internet and did not find a good explanation of how to work with JSON in JS, only $.getJSON(), but it is also not entirely clear for a beginner (JSON2 is not entirely clear, there is no explanation).

The bottom line is that the data is received as text and boolean data (true, false) and when clicked, change to the opposite data, as well as the output of graphs (flot) from the data.

thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-08-29
@Alex_mc

jsonlint.com - check the content and realize what went wrong.
JSON has pretty strict rules, in particular:

[{label: "value"}] // невалидно
[{"label": "value"}] // валидно
[{"label": 'value'}] // невалидно

And don't get confused with hashes and arrays in JS. They only have similar syntax, but JSON is stricter.

E
Evgeny Petrov, 2014-08-29
@Petroveg

Your question is not related to JSON or jQuery at all.
The first is just a data transfer format, the second is a significant simplification of writing code + addition of those properties and methods that the browser may not natively support.
JSON processing - working with objects and arrays (otherwise there is plain plain / text). They just loop through.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question