Closed fredmorcos closed 6 years ago
Absolutely is. I have previously started designing for subset types, but did not finish. Ideally that would allow for distinguishing those Strings that are solely Dates, and those numbers that are always Integers.
Patches welcome, unless you are patient enough to wait for my own :-)
Ideally that would allow for distinguishing those Strings that are solely Dates
Not sure what you mean by that, since JSON has no notion of Date vs String... but it does have a notion of Int vs Int + Frac (Float or Double).
Anyways, I'll wait for you instead :)
There are many JSON APIs that use subset of Strings that parse to some other type:
enum
type.)All these should be recognized with the subset typing, we just need to make sure that subset have either no overlap at all, or one of them is strict subset of the other.
Please go forward if you have time. I am currently focusing my efforts in broader context of AI and Data Science in Haskell.
This one is fixed with release 3.0.0.
I am not sure if this is within scope of the project: If I provide an input file with an array of JSON objects, where the objects have identical properties, I noticed that the integer properties are inferred as
Double
s.Would it be possible to assume these values to be integers first, and only when a double value shows up for the property that the type is promoted to a
Double
?Here is a minimal example:
foo.txt
and the outcome is:
foo-toplevelelt.txt
As you can see,
topLevelEltProperty1
is of typeDouble
whileproperty1
in the input JSON file is never given a double value (ie, all are integers).I expect that
topLevelEltProperty1
is of typeInt
orInteger
.