differentiate between "number" and "integer" as per json schema
alwaysmpe opened this issue · 1 comments
As I understand it while javascript type system does not strictly differentiate between "number" and "integer" the JSON schema does (https://spacetelescope.github.io/understanding-json-schema/reference/numeric.html).
Essentially would it be possible to add an "is_int()" function similar to the "is_number()" function? The exact implementation could vary, (both of the below are mentioned in the above link):
one option would be to return true if the contained number can be exactly represented as an integer. (ie all ints return true, for doubles, round, check equality).
a second option would be to add another enum for int encoded types then return true for is_number() if tag is either int or number, and is_int return true for int tag only.
for both of these some small modification would be needed for the shape checking also.
I'm happy to create a pull request for either of these options.
That link is to a project called "JSON Schema", which is not the same as the JSON spec itself. JSON proper does not have a distinction; see also https://github.com/dropbox/json11/blob/master/json11.hpp#L16-L27