Closed carolynvs closed 5 years ago
In the cnab meeting today we discussed various solutions and decided against converting non-integer numbers to string. The reason being that the schema requires that the value for these fields be represented with a number, and marshaling to a string would require an even more customized version of the json schema draft 7 to allow for the strings.
Right now we are going to switch the schema from number to integer. On the cnab-go side the change we agreed upon is to change from float to integer to store values such as Maximum.
It is up to each calling tool to ensure that Default does not contain a non-integer float.
I'll submit a PR shortly with the proposed change.
Since bundles are written using canonical json, and canonical json does not allow for decimal numbers only integers, our current use of float64 to store properties such as
Maximum
,Minimum
, etc is a problem. Any bundles with any of those fields set is unwritable with an error likejson: unsupported value: 0.5
.Other fields like
Default
allow you to store a decimal number and should also gracefully be handled as part of any fix for the other fields.One fix would be to switch from
float64
tojson.Number
. Then in WriteTo we could check if fields likeDefault
which store aninterface{}
if they contain a non-integer float and stringify it.