I have a Hash:
my_hash = {"[email protected]"=>{"first"=>"Bob", "last"=>"Johnson"}, "[email protected]"=>{"first"=>"Lisa", "last"=>"Dell"}}
When I try to serialize it with my_hash.to_json
this is what I get:
"{\"[email protected]\":{\"first\":\"Bob\",\"last\":\"Johnson\"},\"[email protected]\":{\"first\":\"Lisa\",\"last\":\"Dell\"}}"
How could I convert a Hash to JSON format without getting the escaping characters?
These escape characters escape "
in Ruby String
(your my_hash.to_json
output). If you do
puts my_hash.to_json
you'll see that actually these escape characters aren't added to output string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With