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

Ability to configure indentation #22

Open
hohwille opened this issue Jul 28, 2019 · 5 comments
Open

Ability to configure indentation #22

hohwille opened this issue Jul 28, 2019 · 5 comments

Comments

@hohwille
Copy link

Indent is currently hardcoded:
https://github.com/eclipse-ee4j/jsonp/blob/9892c0658f9d55b819d39039a364df37d1d60202/impl/src/main/java/org/glassfish/json/JsonPrettyGeneratorImpl.java#L31

I prefer two spaces as indendation. To change I would have to replace the entire implementation. It should be trivial to create a configuration property so the indent could be set via the config map supplied to the generator factory.
WDYT?

@keilw
Copy link
Member

keilw commented Aug 2, 2019

It sounds good, but any idea where to store that?
Unlike JSONB this API so far has no config mechanism.

@leadpony
Copy link

leadpony commented Aug 2, 2019

We already have a configuration property PRETTY_PRINTING defined in JsonGenerator interface. I believe this is where additional standard properties should be added.
Also I am implementing this proposed nice feature as a provider-specific configuration property in Joy, which is yet another implementation of JSON-P API.

@keilw
Copy link
Member

keilw commented Aug 5, 2019

That property value is a little weird saying "The value of the property could be be anything.". Meaning it's totally up to an implementation what kind of value they use to control PRETTY_PRINTING.
How does Joy use the existing entry?

@leadpony
Copy link

leadpony commented Aug 5, 2019

If a map given to Json#createGeneratorFactory(Map<Strng,?>) contains the key PRETTY_PRINTING, any implementation of JsonGenerator must do pretty printing, regardless of the value of the key. This feature is equally supported by the Reference Implementation, Apache Johnzon, and Joy.

I added two configuration properties INDENTATION_SIZE and TAB_INDENTATION to my own JsonGenerator which extends the standard interface to control the detail of the pretty printing.
Please see Beyond the Standard API.
I hope that these properties or something similar will be officially added to the JsonGenerator interface of JSON-P API anytime soon at some future date.

@keilw
Copy link
Member

keilw commented Aug 5, 2019

Funny because it's not written down anywhere not even in JavaDoc, maybe you could help with the spec by writing some of that down as mentioned here? ;-)

@lukasj lukasj transferred this issue from jakartaee/jsonp-api Jun 8, 2021
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

3 participants