Answer the question
In order to leave comments, you need to log in
How to parse JSON array without commas?
The server returns the array in this form:
{"Url":"amd_ryzen_5_1600","Title":"AMD Ryzen 5 1600"}
{"Url":"amd_ryzen_7_1700","Title":"AMD Ryzen 7 1700"}
i.e. . without commas.
How can it be parsed? JSON.Parse complains about missing comma:
Uncaught SyntaxError: Unexpected token { in JSON at position 59
Answer the question
In order to leave comments, you need to log in
Corrected)))
You can do this:
Or like this:
PS: I should note that the regular expressions used have a number of limitations. For example, if the data contains nested arrays with objects with a space before the closing bracket, [{...}, {...}, ... ]
then the second option will not work correctly. If there are lines in the data with something like this "} {" or "}{" then both options will stop working
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question