0

I have this text string:

 [[Date.UTC(2012,8, 1), 2],[Date.UTC(2012,9, 31), 3],[Date.UTC(2013,0, 31), 3]]

and when I paste it like that, it works fine, but getting it from a string does not work, Can't seem to use JSON.parse() because of the Date.UTC thing.

http://jsfiddle.net/NmFjj/

two samples shown. I need to be able to convert that string to an array so the highcharts works correctly.

2
  • 1
    if you have no control over the Date.UTC being inserted, chances are you're going to have to :gulp: eval() it first. Commented Jun 28, 2013 at 15:30
  • Eval does work, was hoping there would be a better way. I do control the creation of the text string, and I create the Date.UTC() but it is based on the docs from Highcharts, as that is how they expect dates (at least in the example I saw.) Commented Jun 30, 2013 at 12:24

1 Answer 1

1

Try eval instead of JSON.parse.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.