-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XML to JSON Conversion Issue #707
Comments
What is the issue you're facing?
|
It is merging the same key in single error i want seperate object how can i achieve this |
I'd recommend building two separate xml2js parser files for API calls, as it's the solution which always works. As of recent, you can nest multiple (2) objects in the parser without calling reset. This does require prior CDATA recognising $root as the primary object and changing the default settings, see docs from "mergeargs" to "async". If you haven't fixed it yet, what's the full code you've inputted? As this is a linter issue, I also recommend looking into the eyes bug catcher |
Hi Folks,
I am facing the issue while converting the xml to json
XML I have
<Response> <Audio>https://example.com/audio-files/12345/random-audio.mp3</Audio> <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> </Response>
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
The text was updated successfully, but these errors were encountered: