JSON.parse: unexpected character with no spaces after JSON data in javascript

I get this error when debugging javascript code using highcharts via Firebug. Here are the relevant lines of code:

var valpair = [parseInt(items[0]),cumulative];
rain_series.data.push(JSON.parse(valpair)); 

items[0]- it's simple "1234567", and if I add console.log(valpair)to my code, I get this output: [1234567, 0]which seems to be valid JSON. However, I was stuck in my mistake (I was looking for a solution but could not find it for my case).
Anyone here who knows what I'm doing wrong?

+4
source share
1 answer

, JSON.parse, , . JSON.parse, .

JSON.parse , , , .toString(). valpair = [1234567, 0], valpair.toString() 123457,0 (, , JS: 123457,0 Chrome). JSON: " " - .

+22

Source: https://habr.com/ru/post/1524967/


All Articles