jnunemaker / crack

Really simple JSON and XML parsing, ripped from Merb and Rails.
MIT License
541 stars 93 forks source link

Crack::JSON can't parse valid json string with UTF-8 character #52

Open bblimke opened 10 years ago

bblimke commented 10 years ago

Parsing the following json "{\"data\":\"{\"foo\":\"\u0026\"\"}""` raises "Crack::ParseError".

i.e.

require 'json'
require 'crack'

json = JSON.generate({"data"=>"{\"foo\":\"\\u0026\""})

JSON.parse(json)

Crack::JSON.parse(json)

> `rescue in parse': Invalid JSON string (Crack::ParseError)

This seems to be a problem with Psych not being able to handle well \u0026 character.