json - Parsing an enumerated array of arrays from a string in javascript -
i using google charts , trying switch out data using javascript.
the data generated on server sql database. formatted string (i can format want) , given browser in response ajax requests.
unfortunately haven't been able use json create array matches format used google charts. example of way write variable if being generated directly in javascript: ["united states of america", 7.0287],["canada", 7.3005],["australia", 6.8945]
so, array of arrays, , both arrays enumerated rather associative. json seems work better associative arrays enumerated ones.
i've tried using jquery's parsejson() function, json2.js library.
var sourcedata = '["united states of america", 7.0287],["canada", 7.3005]'; //(the source data pulled ajax, comes in format) var resultarray = new array(); resultarray = json.parse(sourcedata); //doesn't work resultarray = $.parsejson(sourcedata); //doesn't work
any ideas?
that isn't array of arrays, is:
[["united states of america", 7.0287],["canada", 7.3005],["australia", 6.8945]]
without surrounding []
it's syntax error.
Comments
Post a Comment