json icon indicating copy to clipboard operation
json copied to clipboard

Introduce allow_invalid_utf16 option in Boost JSON

Open vaishnavkatiyar opened this issue 1 year ago • 39 comments

Fix: #940

Motivation Boost library provides parsing and serialization algorithms to transform JSON to and from the value container as needed. The current version of the boost JSON library includes an option parse_options::allow_invalid_utf8 to control the treatment of unescaped UTF-8 code units, allowing users to disable the validation of UTF-8 code points. It lacks a similar capability for dealing with invalid UTF-16 surrogate pairs. This limitation becomes apparent when users encounter scenarios involving UTF-16 encoded data with mismatched or out-of-range surrogate pairs, where the existing functionality does not provide adequate support or validation mechanisms. Therefore, extending this functionality to encompass invalid UTF-16 surrogate pairs is necessary to ensure comprehensive handling of different UTF encoding scenarios and enhance the library's robustness and versatility in parsing and serialization tasks involving UTF-16 encoded JSON data.

Design The introduction of the parse_options::allow_invalid_utf16 option grants the allowance of invalid UTF-16 surrogate pairs in strings processed by the parser. When the option is activated, the parser refrains from raising errors for invalid UTF-16 sequences. Instead, it replaces these invalid sequences with the Unicode replacement character.

vaishnavkatiyar avatar Feb 28 '24 13:02 vaishnavkatiyar

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Feb 28 '24 14:02 cppalliance-bot

This looks like it will affect performance, where's the profile output?

vinniefalco avatar Feb 28 '24 14:02 vinniefalco

It usually appears within an hour. I'm not sure performance will be affected, given that this is a special case within a special case.

grisumbras avatar Feb 28 '24 15:02 grisumbras

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Feb 29 '24 16:02 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Mar 04 '24 03:03 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Mar 04 '24 06:03 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Mar 04 '24 10:03 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Mar 20 '24 08:03 cppalliance-bot

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.11%. Comparing base (9f85ed6) to head (dc95216).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #985      +/-   ##
===========================================
+ Coverage    93.08%   93.11%   +0.02%     
===========================================
  Files           87       87              
  Lines         8125     8160      +35     
===========================================
+ Hits          7563     7598      +35     
  Misses         562      562              
Files Coverage Δ
include/boost/json/basic_parser.hpp 100.00% <ø> (ø)
include/boost/json/basic_parser_impl.hpp 98.49% <100.00%> (+0.04%) :arrow_up:

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9f85ed6...dc95216. Read the comment docs.

codecov[bot] avatar Mar 20 '24 09:03 codecov[bot]

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Mar 28 '24 12:03 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Mar 28 '24 13:03 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 02 '24 09:04 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 04 '24 05:04 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 04 '24 05:04 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 06 '24 09:04 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 08 '24 04:04 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 08 '24 18:04 cppalliance-bot

An automated preview of the documentation is available at https://985.jsondocs.prtest.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Apr 08 '24 18:04 cppalliance-bot