Repository navigation
Read decimal values from XML input as numbers - #287
Open
pradeeppeddineni wants to merge 1 commit into
Open
pradeeppeddineni wants to merge 1 commit into
pradeeppeddineni wants to merge 1 commit into
Conversation
GoFSH read XML input with xmlToObj, which keeps decimal values as strings. That made instances from XML get quoted decimals, like position.longitude = "-97.7047386", which SUSHI then rejects. Use xmlToJson and parse the result instead. It writes decimals as JSON numbers, so XML input now gives the same content as the equivalent JSON file. Fixes FHIR#260
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Fixes #260. When GoFSH reads XML input, decimal values come out as strings, so an instance like a Location gets
and SUSHI then fails with "Cannot assign string value". JSON input does not have this problem.
The cause is that readJSONorXML uses xmlToObj from fhir-tool, and xmlToObj keeps decimals as strings on purpose (so it does not lose precision). fhir-tool also has xmlToJson, which writes decimals as real JSON numbers. I switched readJSONorXML to call xmlToJson and parse the result. Now an XML file gives the same content as the matching JSON file, since the JSON path also uses JSON.parse.
Booleans and integers were already converted correctly, so only decimals change. The non-FHIR XML handling is the same as before, because both functions go through the same parsing code and throw the same "Unknown resource type" error.
Testing Instructions:
Related Issue:
Fixes #260