Monday, 15 August 2011

Convert string to array of json objects, rails 3+ -



Convert string to array of json objects, rails 3+ -

i have string

astring='[{"name": "daus", "total": "45", "ios": "30", "android": "15"},{"name": "davus", "total": "38", "ios: 27", "android": "11"}]'

and want convert json via

ajson = json.parse(astring)

but receive error:

json::parsererror: 399: unexpected token @ '{"name": "davus", "total": "38", "ios: 27", "android": "11"}]'

i'm assuming error in way i'm setting initial string haven't been able solve yet.

syntax error:

"ios: 27" -> "ios": "27"

ruby-on-rails json string

No comments:

Post a Comment