Replies: 6 comments 13 replies
-
|
I was not yet aware of that RFC. In general, we have no proper way to configure the serialization function Independent of how to solve this issue (be it with a configuration struct or any other idea), I think supporting RFC 8785 could be a good addition to this library. As first step, it would be good to know which requirements need to be met, and where the library's default behavior deviates. @achamayou Are you interested in working on this issue? |
Beta Was this translation helpful? Give feedback.
-
|
@nlohmann yes, I am. I agree that it does makes sense to start from the spec and compare with the library's defaults and/or range of configurable behaviour, I'd be happy to do that. Is appending to this discussion the best way to do that? |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for pointing out the major potential items @achamayou Small note: for sorting the keys the spec has the following note which makes me think we wouldn't have to convert to UTF-16 in the context of the nlohmann-json library and we could sort the strings as UTF-8 directly (nlohmann-json already assumes property names in UTF-8 from what I understand). Note: For the purpose of obtaining a deterministic property order, |
Beta Was this translation helpful? Give feedback.
-
|
I am taking a closer look. I don't think it'd be too hard to implement, however, one potentially blocking issue I can foresee is that we would need to bring in the code for IEEE double -> string conversion, A reference implementation could be extracted from: https://github.com/ulfjack/ryu/tree/master/ryu Licensing for RYU is dual Boost/Apache2, V8 - BSD. The produced section of code would need to retain the original licensing of the code we'd choose to use. Before getting into it, I would like to have your opinion if merging a PR with such a thing would be something you'd be even willing to consider @nlohmann ? |
Beta Was this translation helpful? Give feedback.
-
|
Any progress on this? I would be tempted to us this for Nix. |
Beta Was this translation helpful? Give feedback.
-
|
A recent use-case in one of my personal projects led me to look into adding RFC 8785 serialization support to this library. I think it would be a nice addition. As already pointed out in this discussion, the two main difficulties of implementing RFC 8785 serialization for this library are the UTF-16 lexicographic key sorting and float-to-string conversion. To explore feasibility, I forked the library and put together a small proof-of-concept demonstrating one possible approach to both. You can find it here. Let's break down the diffs of that PoC:
I checked the implementation against the test cases presented in the RFC and they seem to pass. You can find the test implemented here. @nlohmann Given the additional code footprint required (primarily from adding another double-to-string implementation), would you still be interested in RFC 8785 support being added to the library? If so, I would be open to refining the implementation and creating a PR. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
There is now an RFC describing a canonicalised variant of JSON, of particular interest to users who want to sign and verify JSON-serialised payloads. It seems to me that many aspects of the specification are a matter of configuring/calling nlohmann::json, but a few require slightly more adjustment (ordering in particular).
So I have a couple of questions:
Any other thoughts on the topic are also welcome :)
Beta Was this translation helpful? Give feedback.
All reactions