Try to use quirks_mode

  JSON.parse "\"foo\"", quirks_mode: true
  => "foo"

On Thu, Dec 8, 2016 at 5:49 PM, Andy Jones <Andy.Jones / jameshall.co.uk>
wrote:

> This is all kinds of annoying. JSON will apparently encode a String but
> not decode it? :
>
> [9] pry(main)> "foo".to_json
> => "\"foo\""
>
> [10] pry(main)> JSON.parse "\"foo\""
> JSON::ParserError: 784: unexpected token at '"foo"'
> from /home/jonea/.rvm/rubies/ruby-2.3.2/lib/ruby/2.3.0/json/common.rb:156:in
> `parse'
>
> [11] pry(main)> JSON.parse "foo".to_json
> JSON::ParserError: 784: unexpected token at '"foo"'
> from /home/jonea/.rvm/rubies/ruby-2.3.2/lib/ruby/2.3.0/json/common.rb:156:in
> `parse'
>
>
>
>
> *Click here to view Company Information and Confidentiality Notice.*
> <http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>
>
>
> Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
>
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>