cnabio / cnab-spec

Cloud Native Application Bundle Specification
https://cnab.io
Other
957 stars 99 forks source link

revisit canonical json and non-integer numbers #413

Closed carolynvs closed 3 years ago

carolynvs commented 3 years ago

I am confused about the official spec for canonical json and whether or not it supports non-integer numbers. I think this is the spec and they do say that big/high precision numbers should be stored as strings and parsed in the consumer. They do not rule out all non-integer numbers though.

That spec also says that this go implementation is conformant: https://github.com/cyberphone/json-canonicalization/tree/master/go/src/webpki.org/jsoncanonicalizer

We are currently using docker's canonical json library which does not support non-integer numbers. It has a hard check when marshaling a float that it is a whole number.

I have tried the other library and it round trips the value "1.5" (which is what I have users asking for) fine.

When we changed the spec to exclude non-integer numbers that decision was based on a old?bad? copy of the canonical json spec (I was looking at the spec referenced by the docker library http://wiki.laptop.org/go/Canonical_JSON) instead of the one above. I now believe that was a mistake and that we should revert that change and update cnab-go to use a different library.

Tagging @chris-crone and @technosophos to weigh in.

carolynvs commented 3 years ago

Got the 👍 from Chris to update us to use this other library, which is closer to implementing the full spec.