-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect handling of whitespace when using the JSON serializer #2661
Comments
Indeed, we carefully redid the whitespace handling when we wrote the new serializers (well, they are 3+ years old now, have to stop calling them new), which are described here. The new json serializer will not trim your strings anymore, so that's the most easy way to fix this problem! |
Alright, yes, that works as long as we can upgrade to 5.5.0. Thank you! |
Hi, unfortunately I have to reopen this case. A typical operation for us would be to GET a MedicationRequest, change a property, and then PUT the changed MedicationRequest back to the source server. If we do this, the POCO-serializer in 5.5.0 will not strip whitespace. However, the deserialization of the GET/MedicationRequest call will trim strings, through FhirJsonNode:
So our PUT/update call will still send trim:ed strings to the server. Is there a way around this? |
It's true that the FhirClient will use the legacy validators by default (so users didn't get any unexpected changes when upgrading) However, you can alter this as mentioned here: https://docs.fire.ly/projects/Firely-NET-SDK/en/latest/client/setup.html#selecting-a-serializer If you choose one of the non-legacy serializer modes, this will be solved and FhirJsonNode will not be used. Hope this solves your issue! |
Do you have an example of how to do this when using the FhirClient? This is basically what we are currently using with 5.5:
And the FhirClient is then used when deserializing. |
These settings seem correct and should not trim your whitespaces. |
I think I have found the problem. If you set the serialization engine in the FhirClient constructor via a settings object, everything works. If you set the engine through the SerializationEngine property after FhirClient object creation, it won't be picked up:
I would call this a bug, since other Settings-properties are correctly picked up even if changed later (but with an easy workaround to just send in the serialization engine in the constructor). |
Thanks for hunting this down, that helps! |
…alizer-settings #2661 FhirClient Serialization engine modification
Closed by #2661 |
Describe the bug
The Firely SDK trims whitespace when using the JSON serializer, which is not according to spec. This is a big problem when connecting to a FHIR server that treats leading/trailing whitespace as significant. It is only for XML that there is a recommendation to trim whitespace.
Additionally, for the XML serializer there exists an option to turn of whitespace trimming by setting SerializerSettings.TrimWhiteSpacesInXml to false.
To Reproduce
Expected behavior
Whitespace should not be trimmed by default when using JSON serialization since that is not part of the spec. But since this would be a breaking change it could instead be implemented as an option, TrimWhiteSpacesInJson, not to trim whitespace, like the existing TrimWhiteSpacesInXml property (with a default value of true).
Version used:
Additional context
Robert B has been in contact with you through e-mail.
If desired I can provide a PR.
The text was updated successfully, but these errors were encountered: