org-arl / fjage

Framework for Java and Groovy Agents
https://fjage.readthedocs.io/en/latest/
Other
26 stars 13 forks source link

feat(remote): Use LONG_OR_DOUBLE parsing for Json numbers #287

Closed ettersi closed 1 year ago

ettersi commented 1 year ago

gson.fromJson(json, Object.class) and gson.fromJson(json, Number.class) by default parse any numeric input as a Double even when the input is actually an integer. This PR uses the setObjectToNumber() and setNumberToNumber() functions to change the parsing strategy to LONG_OR_DOUBLE so that (small enough) integers are read as Long and only true floating-point numbers (or very large integers) are read as Double. This feels like a more reasonable default for two reasons: