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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -