specs
specs copied to clipboard
Special number values in TableSchema spec contradict JSON spec
While the TableSchema spec seems mostly written for CSV tabular data and JSON arrays of JSON objects as an encoding added later, the specification for a number field states:
The following special string values are permitted (case need not be respected):
NaN: not a number
INF: positive infinity
-INF: negative infinity
In contrast, the ECMA JSON specification states:
Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted
and the RFC 7159 also contains this statement.
Strictly speaking, this is unsalvageable. As a workaround, we could define that the corresponding string literals can be used, so the following CSV
id, amount
1, 100
2, NaN
would be represented in JSON as
[
{
"id": 1,
"amount": 100
},
{
"id": 2,
"amount": "NaN"
}
]