eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
647 stars 407 forks source link

Safe number convertion ? #1317

Open sbernard31 opened 1 year ago

sbernard31 commented 1 year ago

I will use this issue as a kind of bookmark to store all information about number handling issues/questions in Leshan.

In a general way, our encoder/decoder have to deal with different kind of number encoding.

By default, we should be sure those conversions are done without any information lost. We begin to do that in NumberUtil class but not yet fully done.

Maximize JSON/CBOR interoperability ? Should we limit range and precision of numbers to IEEE 754 binary64 (double precision) to maximize interoperability by default ?

This would affect old JSON / SenML-JSON / SenML-CBOR encoding :

It seems this is a real world question in JSON world : https://github.com/FasterXML/jackson-databind/issues/911

Some links about how to handle this kind of conversion safely :

Non exhaustive list of Leshan issue relative to that :

sbernard31 commented 7 months ago

More safe number conversion question with number attribute : https://github.com/eclipse-leshan/leshan/issues/1583