stleary / JSON-java

A reference implementation of a JSON package in Java.
http://stleary.github.io/JSON-java/index.html
Other
4.54k stars 2.56k forks source link

Separate Control for Type Conversion of Numbers and Booleans in XML to JSON Conversion #841

Open jagsgill opened 11 months ago

jagsgill commented 11 months ago

Hello JSON-java maintainers,

I'm reaching out regarding the keepStrings flag. Currently, this flag controls the type conversion for both numbers and booleans uniformly. In my use case, I require more flexibility to sometimes convert numbers but keep booleans as strings, or vice versa, depending on the particular data representation I need when converting XML to JSON.

So, I am wondering about your thoughts to allow separate control over the type conversion for numbers and booleans.

I believe this change would align with the project's goals to address a major user inconvenience and could be achieved without breaking existing behavior (I'm still reviewing the source code, and would appreciate your comments on feasibility of such a change). Allowing users more control over the data representation would be highly beneficial. Thanks.

stleary commented 11 months ago

@jagsgill Sounds reasonable, no objections to adding more granular flags for this purpose. Please use XMLParserConfiguration, avoid changing any constructors for this class, and use with*() methods to set the new values (there are plenty of example methods in that file). Try to use common and easily understood names for the new flags. Also, please add appropriate comments to the keepStrings flag and the new flags. Don't forget to add unit tests. Thanks!

jagsgill commented 9 months ago

We went with a different solution, so I will close this issue. Thanks for the consideration.

rsel17 commented 9 months ago

Hi @jagsgill

We are facing similar issue in our application, would like to know how you have resolved it