You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the difference between what's legal in JSON and Javascript strings, it's a good idea to escape the two characters that are legal in JSON output but not legal in Javascript output, U+2028 and U+2029, so that the JSON parser's output can be safely used to produce JSONP. See rack/rack-contrib#37 for a more detailed discussion of the rationale.
The text was updated successfully, but these errors were encountered:
Note that this might not be pjson's responsibility. If the intent of pjson is never to be used for producing JSONP, but only "pure" JSON, then special-casing two Unicode characters that are perfectly legal in JSON strings would likely hurt performance a little for no gain. But in that case, it might be a good idea to at least document that these two characters are not escaped, to avoid any surprises: if someone later tries to use the library to produce JSONP, they would need to know that it's their responsibility to search for and escape U+2028 and U+2029.
The library so far has only concentrated on getting the max speed.
I'll see if I can add it without major impact on perf, otherwise I'll document it in the readme as you describe.
for the moment I'll put in a JSONP section explaining this in the README.
I'm going to close this issue and open an new one for v0.2.1 with a asJSONP implementation.
Due to the difference between what's legal in JSON and Javascript strings, it's a good idea to escape the two characters that are legal in JSON output but not legal in Javascript output, U+2028 and U+2029, so that the JSON parser's output can be safely used to produce JSONP. See rack/rack-contrib#37 for a more detailed discussion of the rationale.
The text was updated successfully, but these errors were encountered: