How to convert xml2js response into proper JSON?

125 views Asked by At

I am using the xml2js library to convert some xml to a JavaScript object but I get some weird characters as a response which I am not sure how to interact with. It does not look like normal JavaScript object and I need it to be in JSON which I can then use to create a PDF file.

Here is an example of the response I get:

{\"statusCode\":200,\"body\":\"%PDF-1.3\\r%����\\r%PDF-Writer.NET dbAutoTrack Ltd.\\r2 0 obj\\r<<\\r/Creator (Exact Online)\\r/CreationDate (D:20220411114427+02'00')\\r/ModDate (D:20220411114427+02'00')\\r>>\\rendobj\\r3 0 obj\\r[/PDF /Text /ImageC]\\rendobj\\r7 0 obj\\r<<\\r/Type /XObject \\r/Subtype /Image \\r/Name /I0 \\r/Length 76843 \\r/Width 1545 \\r/Height 2000 \\r/Filter /DCTDecode \\r/ColorSpace /DeviceRGB \\r/Decode [0.0 1.0 0.0 1.0 0.0 1.0]\\r/BitsPerComponent 8\\r>>\\rstream\\r\\n����\\u0000\\u0010JFIF\\u0000\\u0001\\u0001\\u0001\\u0000`\\u0000`\\u0000\\u0000��\\u0000C\\u0000\\b\\u0006\\u0006\\u0007\\u0006\\u0005\\b\\u0007\\u0007\\u0007\\t\\t\\b\\n\\f\\u0014\\r\\f\\u000B\\u000B\\f\\u0019\\u0012\\u0013\\u000F\\u0014\\u001D\\u001A\\u001F\\u001E\\u001D\\u001A\\u001C\\u001C $.' \\\",#\\u001C\\u001C(7),01444\\u001F'9=82<.342��\\u0000C

I want to access the body part but I cannot at the moment.

0

There are 0 answers