Kim Tan
Kim Tan

Reputation: 114

Parsing JSON on Jquery

Hi I have this code to parse JSON on JQUERY

var json_text2 = $.parseJSON('{"data":[["1340650436","2.00000"],["1340736844","4.00000"]],"label":"Waist Size (cm)"},{"data":[["1340736861","3.40000"],["1340650514","4.00000"]],"label":"Arm Size (Inch)","yaxis":"2"}');

BUT I got this error on Firebug

JSON.parse: unexpected non-whitespace character after JSON data

Upvotes: 2

Views: 146

Answers (1)

jackwanders
jackwanders

Reputation: 16050

A valid JSON string needs to be a single object or an array of objects. Wrap your objects in array brackets []:

var json_text2 = $.parseJSON('[{"data":[["1340650436","2.00000"],["1340736844","4.00000"]],"label":"Waist Size (cm)"},{"data":[["1340736861","3.40000"],["1340650514","4.00000"]],"label":"Arm Size (Inch)","yaxis":"2"}]');

Upvotes: 5

Related Questions