question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to convert xml to json with multiple U.Mode?

See original GitHub issue

Such as

String json = U.xmlToJson(xml, U.Mode.REPLACE_SELF_CLOSING_WITH_NULL, U.Mode.REPLACE_EMPTY_VALUE_WITH_NULL);

which can replace self closing with null and also replace empty value with null

Reversely, when convert json to xml

String xml = U.jsonToXml(json, U.Mode.REPLACE_NULL_WITH_EMPTY_VALUE, U.Mode.REPLACE_EMPTY_VALUE_WITH_SELF_CLOSING);

At the same time, I hope to add some new Mode like:

// replace <aaa></aaa> to "aaa": ""
U.xmlToJson(xml, U.Mode.REPLACE_EMPTY_TAG_WITH_EMPTY_VALUE);

and reversely

// replace "a": "" to <aaa></aaa>
U.jsonToXml(json, U.Mode.REPLACE_EMPTY_VALUE_WITH_EMPTY_TAG);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
javadevcommented, May 13, 2021

@dejavuhuh I added new mode REPLACE_EMPTY_STRING_WITH_EMPTY_VALUE to the U.jsonToXml(json) method.

0reactions
javadevcommented, Jun 10, 2021

Hi @dejavuhuh,

The new mode REPLACE_EMPTY_TAG_WITH_NULL replaces emply tag and self closing tag with null.

Read more comments on GitHub >

github_iconTop Results From Across the Web

XML to JSON
Select this option to convert number, boolean, or null elements in the incoming XML document to JSON primitive types. This option is selected...
Read more >
XML to JSON Converter - Oxygen XML Editor
Converting XML to JSON in Oxygen · Select the XML to JSON action from the Tools > JSON Tools menu. · Choose or...
Read more >
How to convert XML to JSON? - ReqBin
The XML to JSON converter lets you convert XML data strings to JSON objects. ... Each XML document can contain multiple objects that...
Read more >
XML to JSON Conversion Issue - Stack Overflow
try entering 1234 as a value for any element in the xsd. You will notice that the converted json for that element becomes...
Read more >
Converting XML to JSON using Python - STechies
Here, you have to first import the xmltodict as well as the json module. Next, create an XML structure and put all of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found