Fixed
Details
Assignee
Garret WilsonGarret WilsonReporter
Garret WilsonGarret WilsonComponents
Fix versions
Priority
Major
Details
Details
Assignee
Garret Wilson
Garret WilsonReporter
Garret Wilson
Garret WilsonComponents
Fix versions
Priority
Created January 30, 2019 at 4:15 PM
Updated February 6, 2019 at 2:19 PM
Resolved February 6, 2019 at 2:19 PM
SURF and TURF shall remove the
#
as the delimiter for the integer type and consider a number an integer if it includes no decimal point or$
decimal type delimiter.SURF and TURF currently use
#
as a delimiter to indicate that a number is of typeurf-Integer
. A large motivation for this is that SURF/TURF is supposed to be JSON backwards-compatible (i.e. we can read JSON as SURF/TURF), and JSON (following JavaScript) only has a "number" type, so all numbers in JSON are only "numbers", which are usually stored as floating point. So in JSON5
and5.0
would both be of type "number", and in JavaScript would be stored in floating point format.Java and other language, on the other hand, indicate the distinction e.g. between
int
anddouble
, so that5
would be an integer and5.0
would represent a floating point number. This certainly makes the serialization more concise.It turns out that the JSON spec is pretty vague about implementation of these "numbers", and in real life it seems that JSON parsers/serializers may actually make a disctinction. There has been discussion (e.g. https://github.com/json-schema-org/json-schema-spec/issues/79 ) about whether things like
5
and5.0
would both satisfy a JSON Schema requirement ofinteger
. Currently the JSON Schema 6.0 specification says:Additionally it seems that Json.NET (I presume come C# library) is making some sort of distinction between floating point and integer in its JSON serialization, judging from https://stackoverflow.com/q/21153381/421049 .
So even if the pure JSON world it would seem that it's not prohibited to use/abuse the JSON format to make a distinction between integers and floating point numbers. In our case, we don't even want to go round-trip—we just want to be able to read a JSON document. Rather than requiring a
#
delimiter, SURF/TURF can just consider integers anything without a decimal point (and without the decimal$
delimiter), similar to what Java does. This still seems JSON compliant as far as reading a JSON document, and even seems consistent with some JSON implementations.