json marshal - how to not encode the special characters ?

250 views
Skip to first unread message

Павел Поляков

unread,
Jan 26, 2014, 7:07:47 AM1/26/14
to golan...@googlegroups.com
Hi,

I'm using the next code to encode the struct to json format:

response, err := json.MarshalIndent(simpleResponse, "", "    ")

And, the produced output is the next:


The original content is the next:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:IJEEwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
      <ns1:IJEE.test_search>
         <user_name xsi:type="xsd:string">kredito</user_name>
         <user_password xsi:type="xsd:string">KffUaj34</user_password>
         <q_type xsi:type="xsd:string">F</q_type>
         <q_query xsi:type="xsd:string">200460105</q_query>
      </ns1:IJEE.test_search>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Question:
Could I configure the json Marshal that way, that it would not encode the special characters, like < and >, so I receive the human-friendly output?
I haven't found anything that I think can help me in the encoding/json docs.

Thanks
 

minux

unread,
Jan 26, 2014, 1:08:43 PM1/26/14
to Павел Поляков, golang-nuts
On Sun, Jan 26, 2014 at 7:07 AM, Павел Поляков <ka-z...@yandex.ru> wrote:
Hi,

I'm using the next code to encode the struct to json format:

response, err := json.MarshalIndent(simpleResponse, "", "    ")

And, the produced output is the next:
The original content is the next:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:IJEEwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
      <ns1:IJEE.test_search>
         <user_name xsi:type="xsd:string">kredito</user_name>
         <user_password xsi:type="xsd:string">KffUaj34</user_password>
         <q_type xsi:type="xsd:string">F</q_type>
         <q_query xsi:type="xsd:string">200460105</q_query>
      </ns1:IJEE.test_search>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Question:
Could I configure the json Marshal that way, that it would not encode the special characters, like < and >, so I receive the human-friendly output?
I haven't found anything that I think can help me in the encoding/json docs.
'<', '>', '&' are encoded because of security implications, and you can't disable this feature.
Reply all
Reply to author
Forward
0 new messages