Do not escape / character when encoding a string as JSON
Original Reporter info from Mantis: luizamerico
-
Reporter name: Luiz Americo
Original Reporter info from Mantis: luizamerico
- Reporter name: Luiz Americo
Description:
Currently, the character '/' is escaped when encoding a string as JSON, so is encoded as /.
The '' , '"' and Control Characters must be escaped in a JSON string. All other characters, including / can be encoded, optionally. See https://tools.ietf.org/html/rfc7159#section-7
In fact most implementations does not encode '/'. The main example is the parser/encoder of ECMAScript (JavaScript) that is standardized: http://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify
For a simple and practical example open a Browser console (F12) and execute
JSON.stringify(location.href)
One example that shows the issue is when generating JSON Schema (http://jsonschema.net) with fpjson:
It will encode
"$schema": "http://json-schema.org/draft-04/schema#", as
"$schema": "http://json-schema.org/draft-04/schema#",
This breaks readability, make the size bigger, without any advantage
Attached patch
Mantis conversion info:
- Mantis ID: 30870
- Fixed in version: 3.1.1
- Fixed in revision: 34819 (#01550dd6)
- Target version: 3.2.0