Skip to content

Instantly share code, notes, and snippets.

/test.md Secret

Created October 26, 2017 08:43
Show Gist options
  • Save anonymous/f2c53d0832d910e16584570d11db531b to your computer and use it in GitHub Desktop.
Save anonymous/f2c53d0832d910e16584570d11db531b to your computer and use it in GitHub Desktop.
wat
#!/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"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment