Skip to content
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

Add a closing tag flag for XML output #748

Closed
derily opened this issue Jun 16, 2023 · 17 comments
Closed

Add a closing tag flag for XML output #748

derily opened this issue Jun 16, 2023 · 17 comments

Comments

@derily
Copy link

derily commented Jun 16, 2023

when JSONObject value is empty string,i need XML.toString output <name></name> not <name/>

@stleary
Copy link
Owner

stleary commented Jun 16, 2023

@derily Can you provide a sample input and the output that you want to get?

@derily
Copy link
Author

derily commented Jun 20, 2023

@derily Can you provide a sample input and the output that you want to get?

input(JSONObject):
{ "name":"derily", "job":"" }
output:
<name>derily</name> <job/>
expect(just not use self closing tag syntax):
<name>derily</name> <job></job>

@stleary
Copy link
Owner

stleary commented Jun 23, 2023

@derily It might be possible to accommodate this with an XMLParserConfiguration option. If no one else picks this up, I will try to get something working this weekend.

@madhavgupta2011
Copy link

madhavgupta2011 commented Jul 10, 2023

Hi, Can I take this up? I'm thinking of adding one more boolean parameter in toString() method of XML class and handle the string builder append as per the boolean parameter. Please let me know if this solution can be improved. I'm willing to take up on this issue.

@stleary
Copy link
Owner

stleary commented Jul 10, 2023

@madhavgupta2011 Thanks, yes you can work on this ticket - FYI you don't need to ask first. Please check whether you can use XMLParserConfiguration to trigger the new behavior.

@madhavgupta2011
Copy link

madhavgupta2011 commented Jul 10, 2023

@stleary I have opened a pull request with my changes and added two unit test cases as well.
Can you please review it?
Link to PR

I couldn't get my head around XMLParserConfiguration so I used the appropriate changes.

@stleary
Copy link
Owner

stleary commented Oct 1, 2023

Fix in progress - #754.

@stleary stleary closed this as completed Oct 1, 2023
@stleary
Copy link
Owner

stleary commented Oct 5, 2023

Re-opening since the PR was not accepted

@stleary stleary reopened this Oct 5, 2023
@stleary stleary changed the title when transform json to xml ,i need control whether use self closing tag Add a closing tag flag for XML output Oct 5, 2023
@stleary
Copy link
Owner

stleary commented Oct 5, 2023

Please use XMLParserConfiguration for the implementation.

dubeyaditya29 added a commit to dubeyaditya29/JSON-java that referenced this issue Oct 5, 2023
dubeyaditya29 added a commit to dubeyaditya29/JSON-java that referenced this issue Oct 5, 2023
@stleary
Copy link
Owner

stleary commented Oct 5, 2023

See comments in your repo.

@rudrajyotib
Copy link
Contributor

@stleary - is this issue still open to be picked?

@rudrajyotib
Copy link
Contributor

@stleary - if no one else is working on it, can you assign it to my name?

@stleary
Copy link
Owner

stleary commented Oct 24, 2023

@rudrajyotib You can work on this issue. The new behavior should be opt-in, by adding a new property to XMLParserConfiguration.

@rudrajyotib
Copy link
Contributor

@stleary sure, I'll start working on it and share the design.

@rudrajyotib
Copy link
Contributor

@stleary @johnjaylward - I am creating a configuration "explicitClosureOfEmptyTag" in XMLParserConfiguration. By default this value will be false, and an explicit end tag will not be created for tag with empty values.
Do you see any issue with the name?

@stleary
Copy link
Owner

stleary commented Oct 25, 2023

@rudrajyotib Please use closeEmptyTag or something similar with fewer chars.

@stleary
Copy link
Owner

stleary commented Oct 28, 2023

Closing due to fixed in #820

@stleary stleary closed this as completed Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants