Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 596 forks source link

XML to JSON Conversion Issue #707

Open gauravs456 opened 1 week ago

gauravs456 commented 1 week ago

Hi Folks, I am facing the issue while converting the xml to json
XML I have

`

<Connect trunk="Opensips-Incoming-ABC_1234567890" callerId="1234567890" webhookUrl="https://webhook.site/abcdefg-hijklmnop-qrstuv-wxyz" webhookMethod="POST" terminateOnHangup="true">+1234567890</Connect>
<Audio>https://example.com/audio-files/67890/another-random-audio.mp3</Audio>

`

The output I am receiving is

{ "Response": { "Audio": [ "https://example.com/audio-files/12345/random-audio.mp3", "https://example.com/audio-files/67890/another-random-audio.mp3" ], "Connect": { "trunk": "Opensips-Incoming-ABC_1234567890", "callerId": "1234567890", "webhookUrl": "https://webhook.site/abcdefg-hijklmnop-qrstuv-wxyz", "webhookMethod": "POST", "terminateOnHangup": "true", "number": "+1234567890" } } }

and the Output I want in json is like

{ "Response": { "Audio": "https://example.com/audio-files/12345/random-audio.mp3", "Connect": { "trunk": "Opensips-Incoming-ABC_1234567890", "callerId": "1234567890", "webhookUrl": "https://webhook.site/abcdefg-hijklmnop-qrstuv-wxyz", "webhookMethod": "POST", "terminateOnHangup": "true", "number": "+1234567890" }, "Audio": "https://example.com/audio-files/67890/another-random-audio.mp3" } } how can i acheive this using the library

Leonidas-from-XIV commented 1 week ago

What is the issue you're facing?

gauravs456 commented 5 days ago

It is merging the same key in single error i want seperate object how can i achieve this