Stream: hapi
Topic: Escaping the character ampersand
Lin Zhang (Jan 11 2022 at 08:57):
When escaping the character ampersand (&) in an address, the json seems right(i.e., "& a m p ;") but the xml shows "& a m p ; a m p ;"(here, extra spacebars for displaying it correctly, and actually there are no such spacebars). Is that right?
Lin Zhang (Jan 11 2022 at 08:58):
My Environment: HAPI-FHIR/5.1.0 (FHIR Client; FHIR 4.0.1/R4; apache)
Vassil Peytchev (Jan 11 2022 at 13:21):
why would you escape it in the JSON representation?
Lin Zhang (Jan 11 2022 at 13:59):
The resource was constructed with the IGeneticClient (See https://hapifhir.io/hapi-fhir/docs/client/examples.html). The JSON and XML instance are both representations of the same result. Without escaping, the script would fail with an error/exception.
Daniel Venton (Jan 11 2022 at 15:14):
What you see would appear to be the xml escaping a json blob (containing json escaping). Which if you want xml to contain json blobs it would be correct. Generally you'd take your source data and escape it one time into the desired format and for a different format you'd start at source (not the previous serialization). Perhaps you have a json deserialize xml serialize process that doesn't un-escape the json before it escapes the data for xml?
Perhaps as stated it shouldn't have been escaped in the json to begin with?
Lin Zhang (Jan 11 2022 at 22:59):
When creating and submitting such an instance, there is no explicit setting(s) to use JSON or XML. At least, the error/exception would be thrown out when trying to generate the XHML narrative.
Last updated: Apr 12 2022 at 19:14 UTC