Skip to content

Add first-class rfl::json read and write flag constants - #80

Open
clockblocker wants to merge 3 commits into
mainfrom
json-flags
Open

clockblocker wants to merge 3 commits into
mainfrom
json-flags

Conversation

@clockblocker

Copy link
Copy Markdown
Owner

Summary

Adds idiomatic inline constexpr read and write flag constants under rfl::json alongside the existing rfl::json::pretty so consumers no longer need to leak raw C YYJSON_* macros for JSONC, JSON5, 2-space pretty-printing, BOM handling, or inf/nan formatting.

Read Flags (include/rfl/json/read.hpp, yyjson_read_flag)

  • stop_when_done, allow_trailing_commas, allow_comments, read_allow_inf_and_nan, read_allow_invalid_unicode, allow_bom, allow_ext_number, allow_ext_escape, allow_ext_whitespace, allow_single_quoted_str, allow_unquoted_key
  • Convenience presets: jsonc = allow_comments | allow_trailing_commas, json5 = YYJSON_READ_JSON5
  • Intentionally excludes unsafe/incompatible flags (YYJSON_READ_INSITU, YYJSON_READ_NUMBER_AS_RAW, YYJSON_READ_BIGNUM_AS_RAW).

Write Flags (include/rfl/json/write.hpp, yyjson_write_flag)

  • pretty (existing), pretty_two_spaces, escape_unicode, escape_slashes, write_allow_inf_and_nan, inf_and_nan_as_null, write_allow_invalid_unicode, newline_at_end
  • Read/write flags with differing bit values (allow_inf_and_nan, allow_invalid_unicode) are explicitly disambiguated with read_ / write_ prefixes.

Verification

  • Full JSON test suite under -Wall -Werror: 331/331 PASSED (including 13 new tests in tests/json/test_json_flags.cpp).
  • Documented in docs/content/supported_formats/json.md.

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.

1 participant