JSON.parse without escaping
Question: Is there anyway to do this in JavaScript:

    
    
    $ cat test.json 
    {"body":"\u0000"}
    
    $ python3 -c 'import json; print(json.load(open("test.json", "r")))'
    {'body': '\x00'}
    

Notice, the data above only one `\` (does not need to be escaped). So you have
the following situation in JavaScript:

    
    
    JSON.parse('{"body":"\\u0000"}') // works
    JSON.parse('{"body":"\u0000"}') // does not work
    

With potentially any UTF-8 data comming from a binary source (websocket), can
this data be processed directly like in the first python example above?


Answer: String characters from `\u0000` through `\u001F` are considered as control
characters, and according to [RFC-7159](http://rfc7159.net/rfc7159) are not
allowed characters to use in JSON and must be escaped, as stated [in section
7](http://rfc7159.net/rfc7159#rfc.section.7).

What you are trying to do is to put unescaped control characters into a JSON,
which clearly not acceptable, you have to escape it first, non of the
languages accept it, even Python.

The correct answer would be place a UTF-8 encoded value into a string
containing a JSON format.

This is a correct JSON, and will be parsed by any JSON parser in any language,
even in JavaScript:

    
    
    {"body":"\u0000"}
    

This is **incorrect** JSON (consider the `[NUL]` as a NUL control character,
as it cannot be represented in text):

    
    
    {"body":"[NUL]"}
    

That's why `JSON.parse('{"body":"\\u0000"}')` works and
`JSON.parse('{"body":"\u0000"}')` doesn't.

Hope, it clarifies what's wrong with your test.

