-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Support for Parsing Exotic NaN, Inf, and -Inf as an Optional Mode
The simdjson library currently adheres strictly to the JSON specification (RFC 8259), which does not allow special floating-point values like NaN, Inf, or -Inf.
However, many real-world datasets (e.g., from scientific computing, machine learning, or legacy systems) use these non-standard representations for special floating-point values.
Proposal
Add an optional parsing mode (e.g., via a flag or parser configuration) to allow parsing of the following exotic float literals:
json
Copy
Edit
{
"value1": NaN,
"value2": Inf,
"value3": -Inf
}
These would be interpreted internally as:
NaN → std::numeric_limits::quiet_NaN()
Inf → std::numeric_limits::infinity()
-Inf → -std::numeric_limits::infinity()
Implementation Ideas
This feature should be opt-in only to preserve spec-compliant behavior by default.
Interoperability with other JSON-like serializers that support exotic floats.
Scientific data interchange formats (e.g., MATLAB-exported JSON, Octave, Scilab, Nelson, etc...).
ECMA-262 JSON.parse disallows these, but many ecosystems use relaxed parsers (yyjson, rapidjson)
Backward Compatibility
There should be no change to existing behavior unless the new parsing flag is enabled.
PS: I would be interested to use simdjson with Nelson (https://nelson-lang.github.io/nelson-gitbook/releases/en_US/v1.14.0/json/index.html)