From: Tony Arcieri Date: 2013-07-02T05:17:23+09:00 Subject: Re: Error with JSON#parse --047d7b3432307eb84404e078ea2e Content-Type: text/plain; charset=ISO-8859-1 Your example string "s" is neither valid JSON or YAML. For starters, the "=>" token is not allowed in either. You can't use :value in JSON either. You need to use the double quoted string "value" On Mon, Jul 1, 2013 at 12:42 PM, Love U Ruby wrote: > The same with `YAML#load` > > require 'yaml' > > s = %q!{:value => [ {"a" => nil, "b" => nil, "c" => 0}]}! > s # => "{:value => [ {\"a\" => nil, \"b\" => nil, \"c\" => 0}]}" > YAML.load(s) > # => > # ~> > /home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in > `parse': (): did not find expected node content while parsing a > flow node at line 1 column 2 (Psych::SyntaxError) > # ~> from > /home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in > `parse_stream' > # ~> from > /home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:153:in > `parse' > # ~> from > /home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:129:in > `load' > # ~> from -:5:in `
' > > -- > Posted via http://www.ruby-forum.com/. > > -- Tony Arcieri --047d7b3432307eb84404e078ea2e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Your example string "s" is neither valid JSON or= YAML. For starters, the "=3D>" token is not allowed in either= . You can't use :value in JSON either. You need to use the double quote= d string "value"


On Mon, Jul 1= , 2013 at 12:42 PM, Love U Ruby <lists@ruby-forum.com> wr= ote:
The same with `YAML#load`

require 'yaml'

s =3D %q!{:value =3D> [ {"a" =3D> nil, "b" =3D>= ; nil, "c" =3D> 0}]}!
s # =3D> "{:value =3D> [ {\"a\" =3D> nil, \"b\= " =3D> nil, \"c\" =3D> 0}]}"
YAML.load(s)
# =3D>
# ~>
/home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in
`parse': (<unknown>): did not find expected node content while pa= rsing a
flow node at line 1 column 2 (Psych::SyntaxError)
# ~> =A0from
/home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in
`parse_stream'
# ~> =A0from
/home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:153:in
`parse'
# ~> =A0from
/home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:129:in
`load'
# ~> =A0from -:5:in `<main>'




--
= Tony Arcieri
--047d7b3432307eb84404e078ea2e--