Maintaining trailing zeros for decimal precision in json output#1497
Maintaining trailing zeros for decimal precision in json output#1497florianschoffke wants to merge 2 commits intoFHIR:masterfrom
Conversation
|
Unfortunately, I think this implementation has some undesirable side effects. Any string which can be turned into a number will end up as a number in the output JSON, regardless of the FHIR field's type. If you can check the FHIR field's type before making this conversion, and only change it when it is an appropriate type, then it would be good. I'm not sure how feasible it is to make that check during This FSH demonstrates a few cases where a string looks enough like a number that it gets turned into a number. The output JSON will have numeric values for all three |
|
Hi @florianschoffke. Thanks again for the contribution! We really appreciate it! Preserving trailing 0s is definitely a pain point that JavaScript/JSON does not make easy. It would be great to have a solution for this. As Mint said, however, we need to be sure we don't break anything else in the process. Have you had a chance to think about the issues that Mint has raised? Do you plan to attempt to address them? |
|
First off thanks for considering! |
Description:
This PR attempts to address the issue of trailing zeros for decimal numbers which are omitted when using Typescript and JSON tooling.
The main idea for solving this issue are twofold:
There was no 'elegant' way that I could see to solve this issue as numbers in Typescript with trailing zeros are represented as plain numbers and fs.outputJSONsync transforms the number 19.00 to 19 as well.
Would be interested if we could work with that solution. If I missed other side effects please let me know.
Testing Instructions:
Run Sushi with this FSH File:
Before the commit the output would be
"valueDecimal": 19Afterwards it is
"valueDecimal": 19.00Related Issue:
#1215