Thanks!! Totally missed that one. Switched to from json.Marshal to 
json.Encode:
            jsonEnc:=json.NewEncoder(file)
            jsonEnc.SetIndent("", tab)
            jsonEnc.SetEscapeHTML(false) 

Works great!!


On Monday, August 12, 2019 at 2:18:02 PM UTC-4, Jesper Louis Andersen wrote:
>
> Documented here: https://golang.org/pkg/encoding/json/#Marshal
>
> There is also a description of how to avoid it.
>
> On Mon, Aug 12, 2019 at 7:39 PM Rich <rma...@gmail.com <javascript:>> 
> wrote:
>
>> Hi I have an application that I wrote that uses JSON for the config file. 
>> The application is a chatbot I use internally and allows users to run linux 
>> commands to get information both locally and via ssh. The chatbot interface 
>> uses basic html to render the output so 90% of the time I want to have the 
>> output be surrounded by "<pre>" and "</pre>". But not every one running the 
>> application may want this, their chatbot may run a commands that that uses 
>> other HTML formatting. So I created a directive in the config file allowing 
>> the user to configure this:
>>
>>         "HTMLFormat": {
>>                 "Start": "<pre>",
>>                 "Finish": "</pre>"
>>         }
>>
>> The problem is that this config file also contains a password -- so I 
>> allow the user to put in clear text the password, and on restart the 
>> password gets encrypted, and then I do a simple json.Marshal and rewrite 
>> the config with the encrypted password:
>>
>>             file, err := json.MarshalIndent(config, "", "   ")
>>             errorHandle(err, "Json Marshal", false)
>>             err = ioutil.WriteFile(cFile, file, 0644)
>>             errorHandle(err, "Write Config", false)
>>
>> In the above, 'config' is the struct that contains all the directive, 
>> 'cFile' is the config file being written.  When the file gets written it 
>> looks like this:
>>  has toIn the json there is a directive for the application to add html 
>> formatting to the start of its output.
>>
>>         "HTMLFormat": {
>>                 "Start": "\u003cpre\u003e",
>>                 "Finish": "\u003e\/pre\u003e"
>>         }
>>
>> Any idea why it's doing this?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golan...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/8a7a344a-55aa-468a-8346-c1db036d8372%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/8a7a344a-55aa-468a-8346-c1db036d8372%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> J.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e269493e-e665-4dee-b7a2-63464c3fd1e1%40googlegroups.com.

Reply via email to