0

This is a straight forward question that's a little tricky to explain if you don't know highcharts. So, with a simple block lets say I want to write `

[{"name":"Name1","data":[{"x":1477621800,"y":114,"name":"Name2"}]`

to insert into my highcharts series.
How do I do insert this into the series? I've tried JSON.parse() but it doesn't work....

Basically, I want to dynamically add data through an input field.

1 Answers1

0

I've tried JSON.parse() but it doesn't work....

That's logical. You are missing }] at the end of the string.

That's why it "doesn't work".

[{"name":"Name1","data":[{"x":1477621800,"y":114,"name":"Name2"}]

There are 2 [ and {, but there are only 1 } and ].

Try using:

JSON.parse(`[{"name":"Name1","data":[{"x":1477621800,"y":114,"name":"Name2"}]}]`)