FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

Implement `JsonParser.getNumberTypeFP()` for binary backends #443

Closed cowtowncoder closed 8 months ago

cowtowncoder commented 8 months ago

Now that https://github.com/FasterXML/jackson-core/issues/1149 has been implemented and there is base implementation of getNumberTypeFP() in JsonParser (which basically just returns "unknown" in all cases), it is necessary to override this for binary formats that have specific types (Avro, CBOR, Ion, Protobuf, Smile all do, I think) to report true underlying type. This will allow achieving good balance between somewhat clashing goals of:

  1. Always retaining accuracy between Decimal and Binary floating-point values, regardless of access patterns, but
  2. Using most efficient access in case of typed calls
  3. Unless overridden by configuration, use actual encoded values (related to efficient access), that is, avoid conversions where not requested (Object, JsonNode, Number target types)

To do that, binary backends should expose true types.

cowtowncoder commented 8 months ago

Completed, merged to master.