how to simulate json format and parse in ruby -
i'm trying simulate json response attaching variable.
myjson = {'link':{ 'href':'erwerweirwierwe', 'rel':'self' }, 'plan':{ 'shortname':'chrome', 'shortkey':'masterfull', 'type':'chain', 'enabled':true, 'link':{ 'href':'something', 'rel':'self' }, 'key':'masterfull', 'name':'teserere' }
when try parse above, error:
parsedjson = json.parse(myjson)
do need format raw json before reading way?
you have use double quotes, not single quotes.
you can validate json using this web service.
also, in example, you're missing last closing brace.
the following json validates:
{ "link": { "href": "erwerweirwierwe", "rel": "self" }, "plan": { "shortname": "chrome", "shortkey": "masterfull", "type": "chain", "enabled": true, "link": { "href": "something", "rel": "self" }, "key": "masterfull", "name": "teserere" } }
Comments
Post a Comment