#!/usr/bin/env ruby
require 'json'
data = JSON.parse(<<JSON
{"foo":"\"bar"}
JSON
)
Doesn't work:
foohost:cwd user$ ./test.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/json/common.rb:155:in `parse': 757: unexpected token at '{"foo":""bar"} (JSON::ParserError)
'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/json/common.rb:155:in `parse'
from ./test.rb:8:in `<main>'
However it does if json is replaced with {"foo":"\\\"bar"}