From: Josh Cheek Date: 2013-07-02T06:53:33+09:00 Subject: Re: Error with JSON#parse --089e01182b3e48ff2f04e07a4294 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jul 1, 2013 at 2:39 PM, Love U Ruby wrote: > require 'json' > > s = %q!{:value => [ {"a" => nil, "b" => nil, "c" => 0}]}! > s # => "{:value => [ {\"a\" => nil, \"b\" => nil, \"c\" => 0}]}" > JSON.parse(s) > # => > # ~> from -:5:in `
' > # ~> > /home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/json/common.rb:155:in > `parse': 757: unexpected token at '{:value => [ {"a" => nil, "b" => nil, > "c" => 0}]}' (JSON::ParserError) > # ~> from > /home/kirti/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/json/common.rb:155:in > `parse' > # ~> from -:5:in `
' > > I have expected - `{:value => [ {"a" => nil, "b" => nil, "c" => 0}]}` > > What the wrong I did here ? > > -- > Posted via http://www.ruby-forum.com/. > > require 'json' require 'yaml' ruby = {:value => [ {"a" => nil, "b" => nil, "c" => 0}]} JSON.dump ruby # => "{\"value\":[{\"a\":null,\"b\":null,\"c\":0}]}" YAML.dump ruby # => "---\n:value:\n- a: \n b: \n c: 0\n" --089e01182b3e48ff2f04e07a4294 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Jul 1, 2013 at 2:39 PM, Love U Ruby <lists@ruby-forum.com<= /a>> wrote:


require '= json'
require 'yaml'

ruby = =3D {:value =3D> [ {"a" =3D> nil, "b" =3D> nil= , "c" =3D> 0}]}

JSON.dump ruby # =3D> "{\"value\":[{\= "a\":null,\"b\":null,\"c\":0}]}"
YAML.dump ruby # =3D> "---\n:value:\n- a: \n =A0b: \n =A0c: 0\n&= quot;

--089e01182b3e48ff2f04e07a4294--