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

Suggestion: Add more constructors with parameters for JSONParserConfiguration #939

Open
Simulant87 opened this issue Jan 11, 2025 · 1 comment

Comments

@Simulant87
Copy link
Contributor

to me it was counter intuitive to create a default configured JSONParserConfiguration to then call withStrictMode() on it returning a clone and making the first instance obsolete. I would even need to create multiple clones until I have the correct configuration, when I want to set multiple values. I would like to be able to create my desired configuration in one go.

This would require a Constructor JSONParserConfiguration(boolean overwriteDuplicateKey, boolean strictMode) or even JSONParserConfiguration(boolean overwriteDuplicateKey, boolean strictMode, boolean keepStrings, int maxNestingDepth).

I would also allow the make the configuration fiels final although that would be a backwards compatible breaking change, and therefore will most probably not be added. I would make it reasier to reason about the codes behaviour and avoid the potential of changing an already used configuration.

What do you think of it?

@stleary
Copy link
Owner

stleary commented Jan 12, 2025

@Simulant87 It is just the practice for configuration classes in this project. You will see similar APIs in JSONMLParserConfiguration and XMLParserConfiguration. Agreed it can be a bit inefficient, but it also has advantages. For example, XMLParserConfiguration has 6 tunable properties. I wouldn't want to be forced to init all of them when only one needs to be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants