On 11:59 AM, Allen Wirfs-Brock wrote:
On Apr 13, 2011, at 6:14 AM, Kyle Simpson wrote:
Many JSON serializer implementations escape the "/" character, including for instance PHP's
json_encode(). However, JavaScript's own JSON.stringify() does not. If you look at the grammar on
json.org, as I read it, the escaping of "/" is **optional**, since it is a valid UNICODE
character, and it's not ", \, or a control character.
As much as possible, we want ECMAScript implementations to behave identically.
For that reason, we specified specific outputs for JSON.stringify, even where
the json refc grammar allowed variation. (For example, in theory every
character could be stringified as a \uxxxx sequence). We can quibble about the
specific encoding choices that were made by ES5 but unless somebody identifies
something that is actually a bug according to the the json rfc grammar I doubt
if we would make a change at this point.
That said, there is nothing stopping someone from defining and promoting for
standardization an additional JSON encoding function that allowed more
explicitly control of the encoding choices. Whether or not it got adopted
would probably depend upon its demonstrated utility.
Allen
The .replace method on the result of .stringify is adequate for HTML or
XML escapement. We don't need to change .stringify for this purpose.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss