Project

General

Profile

Actions

Feature #1055

open

Support alternative keywords for NaN and infinity in dcm2json

Added by Marco Eichelberg over 2 years ago. Updated over 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Library and Apps
Target version:
-
Start date:
2023-01-11
Due date:
% Done:

0%

Estimated time:
Module:
dcmdata
Operating System:
Compiler:

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.


Related issues 1 (1 open0 closed)

Related to DCMTK - Feature #1086: Implement support for DICOM CP 2275 in dcm2jsonNew2023-11-11

Actions
Actions #1

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.

Actions #2

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.

Actions #3

Updated by Marco Eichelberg about 1 year ago

  • Related to Feature #1086: Implement support for DICOM CP 2275 in dcm2json added
Actions

Also available in: Atom PDF