Is the output of dump()
guaranteed to be deterministic across versions?
#2526
-
The Nix package manager is using this library quite a lot internally (and it's awesome btw), and we've been considering using it in a few more places. In some of these places binary reproducibility is very important − we must be sure that serializing the same json document with say That seems to hold so far, but I couldn't find any statement guarantying this in the future. Is this actually guaranteed (except for possible implementation bugs that would have to be fixed of course)? I'm not a json expert, but I guess that stuff like the ordering of objects or the formatting of numbers (or just whitespace) could change from one version to another without changing the semantics of the produced json. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The output of the The only way where the output may change is the representation of numbers. For instance, the JSON values {"number":1000} {"number":1E3} are equivalent. However, in recent versions, the output remained stable. But we do not give guarantees on the written bytes, but only that the output remains equivalent. I will need to add this to the documentation somewhere. |
Beta Was this translation helpful? Give feedback.
The output of the
dump
function should be stable between all versions, as long as you pass the same value of indentation.The only way where the output may change is the representation of numbers. For instance, the JSON values
are equivalent. However, in recent versions, the output remained stable. But we do not give guarantees on the written bytes, but only that the output remains equivalent.
I will need to add this to the documentation somewhere.