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
Calling convert(xml, { format: 'json' }) on XML that includes a text node containing unescaped control characters produces JSON containing those characters:
JSON.parse(json);// should not throwconstobj=convert(xml,{format: 'object'});JSON.stringify(obj)===json;// should be true
Version:
node.js: v14.6.0
xmlbuilder2 2.2.0@master
Additional context
I hit this issue when serializing responses from a SOAP endpoint which contain newline characters within embedded escaped HTML (something like <desc><p>First</p>\n<p>Second</p></desc>). I was initially doing JSON.stringify(convert(xml, { format: 'object' })) before I discovered this API, which seems like a reasonable workaround.
Thanks for this awesome library! ✨
The text was updated successfully, but these errors were encountered:
Calling
convert(xml, { format: 'json' })
on XML that includes a text node containing unescaped control characters produces JSON containing those characters:Similarly other invalid characters are not escaped when emitting JSON. According to the spec,
%x00-19
,\
and"
must be escaped in JSON strings.To Reproduce
Expected behavior
Version:
v14.6.0
2.2.0@master
Additional context
I hit this issue when serializing responses from a SOAP endpoint which contain newline characters within embedded escaped HTML (something like
<desc><p>First</p>\n<p>Second</p></desc>
). I was initially doingJSON.stringify(convert(xml, { format: 'object' }))
before I discovered this API, which seems like a reasonable workaround.Thanks for this awesome library! ✨
The text was updated successfully, but these errors were encountered: