Feature #1055
openSupport alternative keywords for NaN and infinity in dcm2json
0%
Description
In the "extended mode", dcm2json converts floating point numbers that are "not a number" or infinity to the terms "nan", "inf", and "-inf", which are not part of the JSON specification but a (somewhat) common extension.
It seems that various libraries (e.g. https://github.com/Canop/JSON.parseMore and Google gson) use the terms "NaN", "Infinity" and "-Infinity" instead. An alternative "extended mode" should be added that uses these terms.
Finally, in the default strict mode, dcm2json refuses to convert DICOM datasets that contain a floating point value that is nan or inf. According to the JSON specification, these values should be encoded as "null". Check if we can add this as another mode to dcm2json and whether it would cause issues in the conversion of JSON to DICOM.
Updated by Marco Eichelberg over 2 years ago
Gunter Zeilinger adds:
One argument preferring Infinity, -Infinity over inf, -inf may be that Javascript (ECMAScript) specifies "Infinity" and "-Infinity" as valid value of StringNumericLiteral ( https://262.ecma-international.org/13.0/#prod-StringNumericLiteral ), so Number.parseFloat("Infinity") returns Number.POSITIVE_INFINITY as Number.parseFloat("-Infinity") Number.NEGATIVE_INFINITY. But because 'Infinity' is NOT also defined as valid NumericLiterals, eval('Infinity') is expected to fail - even if some Java Script Engines (e.g. Firefox's) also returns Number.POSITIVE_INFINITY.
Updated by Marco Eichelberg over 2 years ago
Gunter Zeilinger has today submitted a draft DICOM CP to DICOM WG6 to allow encoding FL and FD binary values as JSON Number or JSON String - permitting the strings "NaN", "Infinity", "-Infinity" as possible values.
Updated by Marco Eichelberg about 1 year ago
- Related to Feature #1086: Implement support for DICOM CP 2275 in dcm2json added