We have been using xml2Json for a while. As of this week, we are getting âoccasionalâ console errors stating it has been deprecated and to use ârequire(âxml2jsâ)â instead.
On doing this, the format that is created is not as we had before - I am sure there is something really simple we are missing
This is from xml2Json
This is from xml2js
We obviously would like it to have remained the same so our tests do not need rework.
I had essentially the same issue and was able to fix it by setting the explicitArray flag to false, similar to what the previous comment mentioned. It should remove the array structures and 0âs from the json object. There may be other differences but I havenât came across any in the XML responses Iâve worked with recently.
Hi,
Thank you for this snipplet, it allows me to display the response in the console in json format (removing the last line with the deprecated xml2Json).
I am struggling to understand how I can access a particular element of the json object, e.g. the âCoverTypeâ from the above example. I just canât make it work. Would you be able to provide a line that displays the CoverType in the console? Thank you!
Hi. Thanks for trying to help. I finally made it work, just after I posted the message⌠typical. I had a typo in my code (mixup between capital i and small LâŚ), my bad! Additional debugging helped. Sorry for the unnecessary question after all :-/