On Mon, Jul 1, 2013 at 2:39 PM, Love U Ruby <lists / ruby-forum.com> 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 `<main>'
> # ~>
> /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 `<main>'
>
> 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"