Skip to content

Stricter JSON standard conformance#2153

Merged
aleks-f merged 1 commit intopocoproject:developfrom
Burgch:json-utf8-escape
Feb 13, 2018
Merged

Stricter JSON standard conformance#2153
aleks-f merged 1 commit intopocoproject:developfrom
Burgch:json-utf8-escape

Conversation

@Burgch
Copy link
Contributor

@Burgch Burgch commented Feb 13, 2018

pdjson is strict about what it will accept; \\a and \\v are correctly rejected as escape sequences because the JSON standard doesn't support them.

Poco::toJSON uses Poco::UTF8::escape, which utilises the supported C escape sequences of \a -> \\a and \v -> \\v, which makes complete sense for UTF-8 string escaping. However, it will then produce JSON which is non-conforming and will fail if parsed using Poco::JSON::Parser.

This change adds a strictJSON option to Poco::UTF8::escape which allows for strict JSON conformance when required (but off by default for compatibility with existing code). Update Poco::toJSON to use this new argument, and update/add tests where appropriate.

@aleks-f aleks-f merged commit af09a02 into pocoproject:develop Feb 13, 2018
aleks-f pushed a commit that referenced this pull request Feb 13, 2018
Lloyd-Pottiger added a commit to Lloyd-Pottiger/poco that referenced this pull request Sep 24, 2024
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
JaySon-Huang pushed a commit to pingcap/poco that referenced this pull request Sep 24, 2024
* Pick pocoproject#2145

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* Pick pocoproject#2153

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

---------

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants