This commit tries to improve serializeJSON() to get closer to rfc4627.
It includes a more proper quoting of strings and output of integers
instead of floats where appropriate.
Purpose
At the moment the serializeString() method replaces only a subset of control characters that are allowed in JSON, hence stringify() may not serialize to valid JSON.
Goals
Add a better string quoting, closer to rfc4627.
Approach
Add a quote() method that walks through the chars of a string and replaces all escapable chars to their quoted "\uXXXX" counterpart.
This commit tries to improve serializeJSON() to get closer to rfc4627. It includes a more proper quoting of strings and output of integers instead of floats where appropriate.
Purpose
At the moment the serializeString() method replaces only a subset of control characters that are allowed in JSON, hence stringify() may not serialize to valid JSON.
Goals
Add a better string quoting, closer to rfc4627.
Approach
Add a quote() method that walks through the chars of a string and replaces all escapable chars to their quoted "\uXXXX" counterpart.