rsmp-nordic / rsmp_sxl_traffic_lights

RSMP Signal Exchange List (SXL) for Traffic Controllers
MIT License
12 stars 4 forks source link

use only JSON types #133

Closed emiltin closed 3 years ago

emiltin commented 3 years ago

JSON has only integer and float types for numbers, so I think we should stick to these in the specification for messages. Types like long or unsigned integer has no meaning in JSON.

We explicitly state the allowed range anyways.

rafaelcf2 commented 3 years ago

This is regards to ECMA standard

From ECMA-404 (2017)

JSON is agnostic about the semantics of numbers. In any programming language, there can be a variety of number types of various capacities and complements, fixed or floating, binary or decimal. That can make interchange between different programming languages difficult. JSON instead offers only the representation of numbers that humans use: a sequence of digits. All programming languages know how to make sense of digit sequences even if they disagree on internal representations. That is enough to allow interchange.

emiltin commented 3 years ago

You're right. JSON has only a general number type, integer and float are not defined as types, but of course you can send both integers and floats.

JSON Schema has integer and number: https://json-schema.org/understanding-json-schema/reference/numeric.html. So perhaps it would make sense to use these two in the spec. Note that 1.0 is allowed as in integer (but not 1.5).

emiltin commented 3 years ago

also relevant for core

emiltin commented 1 year ago

note: this issue does not cover the general use of array, hashes, etc, only numbers