You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update Encoder with a new charactersToEscape property. If not set, default to <>&
Update https://github.com/basgys/goxml2json/blob/master/encoder.go#L122 to remove <, >, and & specifically and instead check if the b character is contained within the encoder's charactersToEscape. Would also require updating sanitiseString to be a function receiver of *Encoder.
Thoughts? With the changes everything would remain the same (by default) but still allow for folks to customize things as needed.
The text was updated successfully, but these errors were encountered:
Hey,
I'd like to contribute two changes upstream but, before I do, I wanted to get your thoughts on if you think you'd accept the changes.
Change #1 - Preserve Whitespace
I'd like to update https://github.com/basgys/goxml2json/blob/master/decoder.go#L136 to not trim white space. I was thinking, to preserve backwards-compatibility I do the following:
trimNonGraphic
to be a function receiver of*Decoder
Decoder
to have adoNotTrimWhitespace
propertySetDoNotTrimWhitespace
*Decoder` function receiverChange #2 - Customize encoding string sanitization
According to the accepted answer of https://stackoverflow.com/questions/3020094/how-should-i-escape-strings-in-json the only characters we must escape is
\
,"
, and control codes (U+0020 and below). The library currently also escapes<
,>
, and&
. I have an application that needs&
to remain unescaped. I was hoping we could allow for users to customize which characters are escaped while retaining backwards-compatibility with the following changes to https://github.com/basgys/goxml2json/blob/master/encoder.go:charactersToEscape
property. If not set, default to<>&
<
,>
, and&
specifically and instead check if theb
character is contained within the encoder'scharactersToEscape
. Would also require updatingsanitiseString
to be a function receiver of*Encoder
.Thoughts? With the changes everything would remain the same (by default) but still allow for folks to customize things as needed.
The text was updated successfully, but these errors were encountered: