bnclabs/gson

Support for json.Number

prataprc opened this issue · 2 comments

If golang type json.Number is encounter while transforming
value -> {JSON, CBOR, Binary-collate} treat them in the following manner:

While transforming to JSON:

Do nothing, json.Number is just a string and encode them as JSON string.

While transforming to CBOR:

Check if json.Number is negative by checking for a leading - . If so encode it as CBOR-int64, else encode it as CBOR-uint64.

While transforming to Binary-collate:

Check if json.Number is negative by checking for a leading -. Either case, eventually it gets encoded as float64.

Note that collate algorithm transparently treats int, uint, float as
number and make it comparable as same type, as number.

One of the presumption is that json.Number which is an alias of string should not have any leading whitespace.

{Value,CBOR,Binary-collate} -> JSON already supports int64 and uint64.