JSON.stringify </script>

Mike Samuel mikesamuel at gmail.com
Thu Sep 29 16:06:54 UTC 2016


On Thu, Sep 29, 2016 at 8:45 AM, Oriol Bugzilla
<oriol-bugzilla at hotmail.com> wrote:
>> ECMAScript, while highly used in web browsers, should really not care
>> about HTML constructs. That's where WHATWG and W3C come in. I suggest this
>> type of feature should come from one of those groups, not ECMA.
>
> That applies to escaping things like `</script>` or `]]>`, and I agree. But
> as Mike Samuel mentioned, JSON strings containing U+2028 or U+2029 are not
> valid JS expressions. I think it would make sense for `JSON.stringify` to
> escape these.

What is it that you're saying is not in TC-39's bailiwick?

Is it that w3c/whatwg should define what constitutes "embeddable JSON"?

Or is it that if it's worth defining a function that produces
embeddable JSON from an EcmaScript object, that w3c/whatwg should
include that in some set of EcmaScript APIs that it defines?

If you agree with my earlier claim
"""
We're talking about JSON serializers.  Every serializers produces
a subset of the output language. Choices about that sublanguage affect
how easy/hard it is to use that serializer with other tools.
"""
then it seems that TC-39 might take embeddability into account when
crafting the subset of JSON that JSON.stringify produces.


More information about the es-discuss mailing list