XML To JSON Questions
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 99
- Joined: Thu Oct 23, 2008 6:29 am
XML To JSON Questions
I am noticing unexpected behavior with XML to JSON conversions. Here is a sample file I created to illustrate my question:
Based on the XML above, this is how I would expect the JSON to appear post conversion:
This is not happening though. The latest editor converts JSON to this instead:
I searched through all options to not find anything to change this.
Are there any solutions to have the conversion meet expectations?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<root attribute1="" attribute2="">
<node1 attribute1="">
<subnode1>TEST</subnode1>
<subnode2></subnode2>
<subnode3></subnode3>
</node1>
</root>
Code: Select all
{
"root":
{
"attribute1": "",
"attribute2": "",
"node1":
{
"attribute1": "",
"subnode1": "TEST",
"subnode2": "",
"subnode3": ""
}
}
}
Code: Select all
{
"root": {
"attribute1": "",
"attribute2": "",
"node1": {
"attribute1": "",
"subnode1": "TEST",
"subnode2": {},
"subnode3": {}
}
}
}
Are there any solutions to have the conversion meet expectations?
-
- Posts: 81
- Joined: Wed Aug 30, 2017 3:56 pm
Re: XML To JSON Questions
Hi Jamil,
The JSON after conversion should be the one you mentioned, indeed.
I tested and it really seems a problem, a regression compared to version 22.1.
I will log an issue for further investigation.
Best regards,
Teo
The JSON after conversion should be the one you mentioned, indeed.
I tested and it really seems a problem, a regression compared to version 22.1.
I will log an issue for further investigation.
Best regards,
Teo
Teodor Timplaru
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 38
- Joined: Wed Sep 09, 2020 3:17 pm
Re: XML To JSON Questions
Post by florin_nica »
Hi Jamil,
Just a few clarifications related to the XML - JSON conversion. Starting from version 23.0, we made a little change to the conversion of empty XML elements.
Thus, an empty XML element with both start tag and end tag, such as: is converted to an empty JSON Object, i.e. and an empty self-closing XML element, such as: is converted to an empty JSON String, i.e.
We did that in order to preserve the round trip conversion, which would otherwise have been lost because we did not differentiate between these 2 types of elements.
So, if you want the previous post conversion's results, the solution is to use empty self-closing XML elements. There isn't currently an option to control this conversion.
Regards,
Florin
Just a few clarifications related to the XML - JSON conversion. Starting from version 23.0, we made a little change to the conversion of empty XML elements.
Thus, an empty XML element with both start tag and end tag, such as:
Code: Select all
<subnode></subnode>
Code: Select all
"subnode": {}
Code: Select all
<subnode/>
Code: Select all
"subnode": ""
So, if you want the previous post conversion's results, the solution is to use empty self-closing XML elements. There isn't currently an option to control this conversion.
Regards,
Florin
-
- Posts: 99
- Joined: Thu Oct 23, 2008 6:29 am
Re: XML To JSON Questions
florin_nica wrote: ↑Mon Jan 10, 2022 1:15 pm We did that in order to preserve the round trip conversion, which would otherwise have been lost because we did not differentiate between these 2 types of elements.
So, if you want the previous post conversion's results, the solution is to use empty self-closing XML elements. There isn't currently an option to control this conversion.
I am not fully understanding the need for this change, but there is no difference between
Code: Select all
<subnode></subnode>
Code: Select all
<subnode/>
-
- Posts: 38
- Joined: Wed Sep 09, 2020 3:17 pm
Re: XML To JSON Questions
Post by florin_nica »
Hi Jamil,
I added an issue on our issue tracker to investigate the possibility of adding such an option. I will let you know as soon as possible when (or if) this feature will be implemented.
Thank you for your interest and feedback!
Regards,
Florin
I added an issue on our issue tracker to investigate the possibility of adding such an option. I will let you know as soon as possible when (or if) this feature will be implemented.
Thank you for your interest and feedback!
Regards,
Florin
-
- Posts: 38
- Joined: Wed Sep 09, 2020 3:17 pm
Re: XML To JSON Questions
Post by florin_nica »
Hi Jamil,
I'm coming back to you with some good news. We added an option to control the desired output when converting XML to JSON, as you suggested. The new option is available in the new version of Oxygen 24.1 released yesterday.
Best regards,
Florin
I'm coming back to you with some good news. We added an option to control the desired output when converting XML to JSON, as you suggested. The new option is available in the new version of Oxygen 24.1 released yesterday.
Best regards,
Florin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service