From 58250e9b3f39f2bace0a43fa31b259545da095f0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 30 Sep 2026 10:00:44 +0200 Subject: [PATCH] Update stale serializer doc comments to match the current implementation dump_internal()'s doc block still described the pre-#5285/#5449 implementation: an escape_string() function that does not exist (the function is dump_escaped), integer conversion "implicitly via operator<<" (dump_integer actually uses a digit-pair lookup table), and floating-point conversion via "%g" (IEEE-754 types go through to_chars, others through snprintf). dump_value()'s comment said elements are pushed for dump_internal to walk, but it is dump_iteratively() that walks the stack. dump_escaped(), dump_integer() and dump_float() each said they write "to output stream @a o", which has not been true since the writer moved to write_buffer. Doc-only change; no behavior, API or ABI impact. Part of #5709 Signed-off-by: Niels Lohmann --- include/nlohmann/detail/output/serializer.hpp | 15 ++++++++------- single_include/nlohmann/json.hpp | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index aa94ea7b5..23185b17e 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -105,9 +105,10 @@ class serializer additional parameter. Arrays and objects are serialized without recursion, however deeply they are nested. - - strings and object keys are escaped using `escape_string()` - - integer numbers are converted implicitly via `operator<<` - - floating-point numbers are converted to a string using `"%g"` format + - strings and object keys are escaped using @ref dump_escaped + - integer numbers are converted using a digit-pair lookup table (@ref dump_integer) + - floating-point numbers are converted to a string using @ref dump_float, which + uses `to_chars` for IEEE-754 types and `snprintf` otherwise - binary values are serialized as objects containing the subtype and the byte array @@ -448,7 +449,7 @@ class serializer @brief serialize the value @a val, but not the elements of a container An object or array with elements is opened and pushed onto @a stack for - @ref dump_internal to walk; everything else - including a binary value, + @ref dump_iteratively to walk; everything else - including a binary value, which looks like an object but has no elements to descend into - is written out in full by @ref dump_scalar. */ @@ -687,7 +688,7 @@ class serializer Escape a string by replacing certain special characters by a sequence of an escape character (backslash) and another character and other control characters by a sequence of "\u" followed by a four-digit hex - representation. The escaped string is written to output stream @a o. + representation. The escaped string is appended to @ref write_buffer. @param[in] s the string to escape @@ -1321,7 +1322,7 @@ class serializer /*! @brief dump an integer - Dump a given integer to output stream @a o. Works internally with + Dump a given integer, appending it to @ref write_buffer. Works internally with @a number_buffer. @param[in] x integer number (signed or unsigned) to dump @@ -1412,7 +1413,7 @@ class serializer /*! @brief dump a floating-point number - Dump a given floating-point number to output stream @a o. Works internally + Dump a given floating-point number, appending it to @ref write_buffer. Works internally with @a number_buffer. @param[in] x floating-point number to dump diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 6515ee4c4..1b0bc1f41 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -24184,9 +24184,10 @@ class serializer additional parameter. Arrays and objects are serialized without recursion, however deeply they are nested. - - strings and object keys are escaped using `escape_string()` - - integer numbers are converted implicitly via `operator<<` - - floating-point numbers are converted to a string using `"%g"` format + - strings and object keys are escaped using @ref dump_escaped + - integer numbers are converted using a digit-pair lookup table (@ref dump_integer) + - floating-point numbers are converted to a string using @ref dump_float, which + uses `to_chars` for IEEE-754 types and `snprintf` otherwise - binary values are serialized as objects containing the subtype and the byte array @@ -24527,7 +24528,7 @@ class serializer @brief serialize the value @a val, but not the elements of a container An object or array with elements is opened and pushed onto @a stack for - @ref dump_internal to walk; everything else - including a binary value, + @ref dump_iteratively to walk; everything else - including a binary value, which looks like an object but has no elements to descend into - is written out in full by @ref dump_scalar. */ @@ -24766,7 +24767,7 @@ class serializer Escape a string by replacing certain special characters by a sequence of an escape character (backslash) and another character and other control characters by a sequence of "\u" followed by a four-digit hex - representation. The escaped string is written to output stream @a o. + representation. The escaped string is appended to @ref write_buffer. @param[in] s the string to escape @@ -25400,7 +25401,7 @@ class serializer /*! @brief dump an integer - Dump a given integer to output stream @a o. Works internally with + Dump a given integer, appending it to @ref write_buffer. Works internally with @a number_buffer. @param[in] x integer number (signed or unsigned) to dump @@ -25491,7 +25492,7 @@ class serializer /*! @brief dump a floating-point number - Dump a given floating-point number to output stream @a o. Works internally + Dump a given floating-point number, appending it to @ref write_buffer. Works internally with @a number_buffer. @param[in] x floating-point number to dump