Escaping of forward slashes in JSON-LD

On Mon, Aug 29, 2011 at 8:03 AM, Thomas Steiner <tomac@google.com> wrote:
> It has become a sometimes observable practice among JSON providers who
> deliver JSON over the Web in a way that it might end up in a <script>
> tag to escape forward slashes (aka. solidus) with a backward slash
> like so: "\/". This is due to the fact that within a <script> tag the
> string "</" may not occur. Given the ubiquity of IRIs (typically in
> the form of "http://") in JSON-LD (well, RDF in general), I was
> wondering whether we should make a statement with regards to forward
> slash escaping in the JSON-LD spec (i.e., "http:\/\/"). Note: escaping
> forward slashes is not required [1], however, e.g., PHP's
> json_encode() function by default adds slashes, whereas JavaScript's
> JSON.stringify() function does not. Opinions?
>
>

I added an issue about this.  A note should be added in the JSON-LD
spec normalization section about the issue but I'm not sure if the
spec needs to mandate one behavior over another.  It's more an issue
for JSON-LD applications that need consistent serialized JSON-LD.  If
you are just dealing with the object model itself you'll never see
this issue.

https://github.com/json-ld/json-ld.org/issues/22

-dave

Received on Wednesday, 31 August 2011 20:45:52 UTC