Repository navigation
Add opt-in <rfl/nlohmann.hpp> adapter for nlohmann::json - #69
Open
clockblocker wants to merge 3 commits into
Open
clockblocker wants to merge 3 commits into
clockblocker wants to merge 3 commits into
Conversation
- N1: Add vcpkg nlohmann feature, conan with_nlohmann option, and wire REFLECTCPP_NLOHMANN into REFLECTCPP_ALL_FORMATS and vcpkg features. - N2: Enforce nlohmann_json >= 3.11.3 in CMake, package config, and Reader.hpp static_assert. - N3: Add is_nlohmann_reader_v/is_nlohmann_writer_v and lossless cross-BasicJson conversion; guard uint64_t and YAML quoted strings (Tag() == "!") in read_from_generic_reader. - N4: Support rfl::Vectorstring and nlohmann binary_t <-> Bytestring/Base64. - N5: Extract opt-in nlohmann/adl_serializer.hpp guarded by __cpp_exceptions, drop 2-arg from_json for Validator/const-field support, and throw BasicJsonType::other_error::create(501, ...). - N6-N8: Rename detail -> internal, use emplace + reserve in Writer, use BasicJson::string_t in Reader::find, add docs and expanded tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in, header-only
nlohmann::jsonadapter (<rfl/nlohmann.hpp>) supporting directrfl::nlohmann::read<T, Ps...>/rfl::nlohmann::write<Ps...>, losslessnlohmann::basic_jsonfields inside reflected structs across formats, and opt-innlohmann::adl_serializerintegration (<rfl/nlohmann/adl_serializer.hpp>).Reconciled Review Fixes (N1–N8)
REFLECTCPP_NLOHMANNintoREFLECTCPP_ALL_FORMATS,vcpkg.json(nlohmannfeature), andconanfile.py(with_nlohmann).nlohmann_json >= 3.11.3inCMakeLists.txt,reflectcpp-config.cmake.in, andReader.hppstatic_assert.is_nlohmann_reader_v/is_nlohmann_writer_v, lossless cross-basic_jsonconversion, and guardeduint64_tand YAML quoted strings (Tag() == "!") inread_from_generic_reader.rfl::Vectorstringandnlohmann::binary_t<->Bytestring/Base64.<rfl/nlohmann/adl_serializer.hpp>guarded by__cpp_exceptions, dropped 2-argfrom_json(preservingValidatorandconst-field support), and throwBasicJsonType::other_error::create(501, ...).detail->internal, usedemplace+reserveinWriter, usedBasicJson::string_tinReader::find, addeddocs/content/supported_formats/nlohmann.md, and verified all 3 CMake matrix configs + standalone header compilation under-Wall -Werror.Verification
REFLECTCPP_JSON=ON -DREFLECTCPP_NLOHMANN=ON: 591/591 passedREFLECTCPP_JSON=OFF -DREFLECTCPP_NLOHMANN=ON: 8/8 passedREFLECTCPP_NLOHMANN=OFF: 582/582 passed