I have a http response body that is in JSON however it contains one field and that is an XML document as a string. I do not want to parse the XML at all, I just want to extract it because I need to send it somewhere else as XML. When I attempt to use:
body, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
var ccr []models.Ccda
err = json.Unmarshal(body, &ccr)
The Model is this:
Ccda struct {
CCDA string `json:"ccda"`
}
I get an err of "invalid character '<' looking for beginning of value"
I have attempted it with string maps also and still same error.
The beginning of the json response is:
[{
"ccda": "<?xml version=\"1.0\"?>
<ClinicalDocument xmlns=\"urn:hl7-org:v3\"..."
}]
ccda is the only element in the json string. Again, I have no desire to parse the XML.
Is there a problem with the way GO is handling the escaped quotes? The value of the json element ccda is the XML string.
Looking at the raw data from the vendor's site(their tool) I get this:
[{ "ccda": " }]
When I read the response.Body and convert to string I get this (it is incorrect, though I may be able to use it):
<?xml version="1.0"?>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc">
<realmCode code="US"/>
<typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
<templateId root="2.16.840.1.113883.10.20.22.1.1"/>
<templateId root="2.16.840.1.113883.10.20.22.1.2"/>
<id root="0cf1a768-2016-505e-2fd3c-001A64958C30"/>
<code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note"/>
<\ClinicalDocument>
When I do other calls for other information in GO, I do get back the proper JSON on all tests go/ruby/site tools. just not on this call on GO.