Simplify the serializer as suggested in review

- Test JSON_LITTLE_ENDIAN_TARGET (#5876) instead of repeating its condition
  as JSON_DUMP_SHORT_STRINGS.
- Let dump() write a top-level scalar through dump_element(), so that
  dump_internal() becomes dump_container() and handles objects and arrays
  only; pass 0 as indentation on the compact paths.
- Rename put_quoted() to put_object_key(), its only use.
- Share the fast path of put_indent() and put_literal_indent() in
  put_short_literal_indent(), and use put_literal_indent() for binary values
  and the closing brackets of dump_iteratively().
- Assert that write_u_escapes() sees sequences of 2 to 4 bytes only.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-22 19:41:03 +02:00
1 parent ff8ba3cb74
commit a800ded53d
3 files changed
+330 -384

No files matched your search

@@ -33,7 +33,6 @@
#undef JSON_SCAN_SSSE3_TARGET
#undef JSON_SCAN_VECTOR
#undef JSON_SCAN_VECTOR_UTF8
#undef JSON_DUMP_SHORT_STRINGS
#ifndef JSON_TEST_KEEP_MACROS
#undef JSON_CATCH