-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should it be possible to round-trip json? #368
Comments
Can you try compiling the atd with |
Yeah that fixed it! Thanks for the quick response @cyberhuman! This feels like it might be worth a mention somewhere close to where variants are shown. EDIT: Now that I know what I'm looking for I found the relevant documentation. Unfortunately I have no good suggestion for how to make this more discoverable. |
Yes. The only issue is backward compatibility. We might want to release this as part of a major version release. I started a list here. |
On the topic of round-tripping is there a way to work-around this behaviour?
let t = My_type_t.{ my_number = 65.26; my_key = "ABC" }
let () =
Printf.printf "%f" t.my_number;
(* Prints: "65.260000" *)
Printf.printf "%s" (My_type_j.string_of_my_type t)
(* Prints: "{\"my_number\":65.26000000000001,\"my_key\":\"ABC\"}" *) I would be okay parsing |
It's best to open a new issue for each new question. Printing
The internal representation of OCaml floats or C doubles (IEEE-754 binary-64) is binary rather than decimal and provides no clue that there's a short decimal representation for the number. Printing a sufficiently large number of decimal digits (17 digits or so) ensures that parsing the string in decimal notation will recover the original float. Maybe there are tricks we could use to print |
I was caught by surprise when trying to round-trip some json following this example in the documentation. Is round-tripping supposed to work?
Notice how
"black"
comes back as<\"black\">
.The same behaviour is also present when using
<ocaml repr="classic">
.The text was updated successfully, but these errors were encountered: