0
votes

I am new to jQuery and json. Trying to draw a graph with reference to the demo from http://www.highcharts.com/stock/demo/

This graph uses data from a json file

http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?

this file directly started with data. But the json file that I want to use looks something like this

{"name": { "text1": "on", "data": { [1147651200000,67.79], [1147737600000,64.98], [1147824000000,65.26], [1147910400000,63.18], [1147996800000,64.51], [1148256000000,63.38], [1148342400000,63.15], [1148428800000,63.34], [1148515200000,64.33], [1148601600000,63.55], [1148947200000,61.22], [1149033600000,59.77], } }}

could someone help me with this please

1
not valid json ...check here jsonlint.comghost
Parse error on line 4: ...ata": { [ 11 ----------------------^ Expecting 'STRING', '}'Mohammad Adil
replace the { with '[' in data part that will make your json validSaurabh
But what is your problem, because jsonp from url works properly.Sebastian Bochan

1 Answers

0
votes

Your json is invalid.

If your data property is an array, so you should use [] to denote the array.

I'm assuming that array is an array of arrays, so inside [], it should have multiple []s.

Like:

[[x1,y1],[x2,y2]...]

Try formatting your code sample as follows...

{
    "name": {
        "text1": "on",
        "data": [
            [
                1147651200000,
                67.79
            ],
            [
                1147651200000,
                67.79
            ]
        ]
    }
}

Use something like http://jsonlint.com/ to check your json's validity.