Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Consider adopting the Ryu algorithm #130
The Ryu algorithm (https://github.com/ulfjack/ryu) for IEEE-754 serialization offer a number of interesting features such a simple, fast and (with a minor tweak) 100% compatible with ES6. Using the Ryu algorithm also makes https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-06 more realistic for JSONB, particularly with the proposed upgrade in eclipse-ee4j/jsonp#160. Here is a comparison made between String.valueOf(double) and my Ryu adaption for Java where each value has been serialized 1M times.
Looks it is compatible but it is also a draft so quite bad for a jakata spec - keep in mind jsonschema which is in draft already broke features. Also nothing requires an impl to use valueOf - guess they all do but this is not required AFAIK since not part of user facing API - this is why it is an impl detail for me.
So only question is for me the json number representation and while any round trip (java/json) works - which means js can consume it - I guess we are covered at spec level.
If a new final json spec pops up it could become a toggle - config property and annotation - IMHO.
Does it make sense?
@rmannibucau JS (as well as any correctly implemented JSON parser), can consume both your existing and proposed format, it is only canonicalization that requires absolute ES6 compliance.
Regarding JDK roundtripping, the ES6/Ryu adaptation succeeds using my 100M test file:
I would not bother with a toggle since the "problem" rather is in the spec.
The test program failed on C# but it turned out to be due to a bug in the .NET number parser. After reporting it, Microsoft fixed it as well!
JSON Canonicalization now works on 5 platforms.