Repository navigation
Replies: 2 comments
|
Hi @nlohmann, Thanks for opening this discussion. Using JCS as the pilot case for the companion header concept makes a lot of sense. Here are my thoughts mapped directly to your open questions:
Decision on Integers (> ±2^53 for JCS):It helps to separate serialization semantics from the accepted-input policy:
I can prepare a public-API-only JCS prototype ( |
|
I can offer #5959 (my static-reflection proposal, currently waiting for your Scope. A companion header, in my reading: optional functionality shipped Support level. A useful split might be: core ( Public API vs Naming and API shape. Packaging checklist (amendments welcome):
Versioning. Same library version and ABI namespace; the tier decides the For #5871, I'd only note here: if it moves to a companion header, Questions: (a) is "experimental companion" a tier you want? (b) strict Happy to adjust #5959 to whatever list is settled and to rebase onto a develop |
Uh oh!
There was an error while loading. Please reload this page.
PR #5871 adds RFC 8785 (JSON Canonicalization Scheme) serialization. During review, we agreed the feature fits better in a separate header built on top of
json.hppthan in the core serializer. That raises a question we haven't answered so far: what is our concept for optional companion headers? I'd like to settle that before #5871 (or any similar feature) goes that way, so I'm opening it up for discussion.What we have today
There are two precedents, built differently:
json_literals.hppsingle_include/<nlohmann/json.hpp>(public API)json_view.hppjson.hppstays an external includejson.hppplus its owndetail/view/*Both are fully supported, documented, tested and listed in
BUILD.bazel. There is one known rule: a companion header includes only<nlohmann/json.hpp>from outside its owndetailsubfolder. Otherwise the amalgamation inlines library internals a second time.Open questions
json_view), convenience (literals)? Where's the line between a companion header and "a separate project that depends on nlohmann/json"?json.hpp(API stability, the full compiler matrix, release notes), or a lighter "experimental"/"contrib" tier? If there's a lighter tier, how is it marked (namespace, macro, docs)?detail/allowed?detail/avoids that duplication, but couples the header to every internal refactoring.json_<feature>.hpplike the existing ones? Free functions templated onBasicJsonType, rather than newbasic_jsonmembers?check_amalgamation.yml.cppand.outputFirst candidate: JCS (#5871)
For RFC 8785 specifically, a public-API-only version looks feasible and small:
dump()already escapes strings the way JCS requires.dump()of a double already gives the shortest round-trip digits; only the ECMAScript layout of those digits has to be redone.It also needs a decision on integers beyond ±2^53, which JCS requires to be rounded to double. The two options are to throw or to round.
Feedback welcome, especially from people who would use such headers or who package the library.
— posted by Claude Code on behalf of @nlohmann
All reactions