It turns out it was the emoticon in his message that was causing the
problem, but my testing was invalid. This is interesting (keeping in
mind that in the status ":-\" had been converted to ":-\\"):

>> Crack::JSON.parse('{"a":"b\"}')
Crack::ParseError: Invalid JSON string
        from /usr/lib/ruby/gems/1.8/gems/crack-0.1.1/lib/crack/json.rb:
14:in `parse'
        from (irb):949
>> Crack::JSON.parse('{"a":"b\\"}')
Crack::ParseError: Invalid JSON string
        from /usr/lib/ruby/gems/1.8/gems/crack-0.1.1/lib/crack/json.rb:
14:in `parse'
        from (irb):950
>> Crack::JSON.parse('{"a":"b\\\"}')
=> {"a"=>"b\\"}
>> Crack::JSON.parse('{"a":"b\\c"}')
=> {"a"=>"b\\c"}
>> Crack::JSON.parse('{"a":"b\c"}')
=> {"a"=>"b\\c"}

ActiveSupport::JSON.decode behaves exactly the same way (I'm sure
Crack is wrapping it). I'm still not sure what to make of this. Is
this a parsing bug in ActiveSupport::JSON?

I'm waiting on a JS expert I know to get back to his desk to tell me
whether {"a":"b\\"} is valid JSON or not (as before, JSONLint says it
is).

Reply via email to