0

I have json like this in a string:

([[1130112000000,56.79],[1130198400000,56.10]]);

The original json is here : highcharts json

and it use in here : highcharts example

In highcharts example they have used getJSON with a link of json inside it.

But in my program i'm generating json in the same page and i have no idea have to parse it for script!!

2
  • Your example is not valid JSON. Commented Oct 22, 2012 at 16:14
  • I know it not a valid json, that why i ask this question. any way this is how it's use in highcharts Commented Oct 22, 2012 at 16:20

3 Answers 3

1

Looking at the jsFiddle that highcharts provides, they're retrieving their json through their own callback, taking the returned data and feeding it through their new Highcharts.StockChart function.

To use your own json(must be properly formed json, try this to help...), create the structure then do the same exact call to highcharts that they show in their example but replace the data variable with your data variable...

it will work without issue if everything is setup correctly...

if this doesn't help, please post more information on what you're attempting to do (with code) or else we will be going in circles...


Here is a jsFiddle example taking the points you posted in your question and using it to create a simple highcharts graph...

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

Comments

0

Assuming your JSON is valid, give this a try:

var data=jQuery.parseJSON(data);

Comments

0

That format is called JSONP.

Notice that the data starts with ?() because you specified the callback as http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?

You're supposed to call it specifying a method you want to use as the callback to process the data

Therefore, you can use http://jsfiddle.net/AF4ru/

$.ajax({
  url: 'http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=hello',
  dataType: 'jsonp',
  success: function(data){
    console.log(data);
  }
})​​​​​​​;​

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.