sinelaw / xml-to-json-fast

Fast, light converter of xml to json capable of handling huge xml files
MIT License
49 stars 6 forks source link

Incorrent &#xA (line feed) decoding #9

Open svarzee opened 3 years ago

svarzee commented 3 years ago

Running: xml-to-json-fast <<< '<tag>some text &#xA some text</tag>' Yields:

{"name": "tag", "items": [ 
"some text 
 some text"
]}

Which is incorrect json, it should be:

{"name": "tag", "items": [ 
"some text \n some text"
]}
svarzee commented 3 years ago

The same applies to \t

svarzee commented 3 years ago

Fix in StreamingXmlToJson.hs

 57 encodeStrInternal ('\n':s) = '\\':'n': encodeStrInternal s
 58 encodeStrInternal ('\t':s) = '\\':'t': encodeStrInternal s