From b167096e82abf72cfb63a45631a5adeb926abd86 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 22 Dec 2024 14:20:10 +0100 Subject: [PATCH] :memo: clean up --- docs/mkdocs/docs/api/basic_json/dump.md | 4 ++-- docs/mkdocs/docs/api/basic_json/error_handler_t.md | 2 +- tests/src/unit-regression2.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/mkdocs/docs/api/basic_json/dump.md b/docs/mkdocs/docs/api/basic_json/dump.md index 30388f660..1ff15e3f6 100644 --- a/docs/mkdocs/docs/api/basic_json/dump.md +++ b/docs/mkdocs/docs/api/basic_json/dump.md @@ -28,8 +28,8 @@ and `ensure_ascii` parameters. : how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md)): : - `strict`: throws a [`type_error`](../../home/exceptions.md#type-errors) exception in case a decoding error occurs (this is the default), - `replace`: replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER), - - `ignore`: ignore invalid UTF-8 sequences during serialization, and - - `keep`: keep invalid UTF-8 sequences during serialization; all bytes are copied to the output unchanged + - `ignore`: ignore invalid UTF-8 sequences during serialization (i.e., these bytes are skipped and not copied to the output), and + - `keep`: keep invalid UTF-8 sequences during serialization (i.e., all bytes are copied to the output unchanged) ## Return value diff --git a/docs/mkdocs/docs/api/basic_json/error_handler_t.md b/docs/mkdocs/docs/api/basic_json/error_handler_t.md index 1b3c7456a..437abdc61 100644 --- a/docs/mkdocs/docs/api/basic_json/error_handler_t.md +++ b/docs/mkdocs/docs/api/basic_json/error_handler_t.md @@ -18,7 +18,7 @@ replace : replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER) ignore -: ignore invalid UTF-8 sequences +: ignore invalid UTF-8 sequences; these bytes are skipped and not copied to the output keep : keep invalid UTF-8 sequences; all bytes are copied to the output unchanged diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index b8c8b782f..29bfdf541 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -1000,8 +1000,11 @@ TEST_CASE("regression tests 2") { nlohmann::json node; node["test"] = "test\334\005"; - const auto test_dump = node.dump(-1, ' ', false, nlohmann::json::error_handler_t::keep); - CHECK(test_dump == "{\"test\":\"test\334\005\"}"); + auto x = node.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore); + + CHECK(node.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore) == "{\"test\":\"test\\u0005\"}"); + CHECK(node.dump(-1, ' ', false, nlohmann::json::error_handler_t::keep) == "{\"test\":\"test\334\005\"}"); + CHECK(node.dump(-1, ' ', true, nlohmann::json::error_handler_t::keep) == "{\"test\":\"test\334\005\"}"); } }