-
Notifications
You must be signed in to change notification settings - Fork 186
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
Support custom JSON formatting #10
Comments
@ralfstx do you think you will have time to work on this issue? In my case I need to generate JSON with indentation. |
Actually, I'm currently working on it ;-) My plan is to start with a built-in pretty-printer that outputs each value on a separate line, indented by 2 spaces, for example: {
"an-array": [
23,
"foo",
null
],
"an-object": {
"a": true,
"b": "foo\\bar"
}
} I guess that will be okay in most cases. Would that be sufficient for you as well? |
@ralfstx very cool! I'm waiting for your release in order I will integrate it to tern.java. Thanks! |
A new optional parameter jsonValue.toString(WriterConfig.PRETTY_PRINT);
jsonValue.writeTo(writer, WriterConfig.PRETTY_PRINT); More fine-grained parameters will be added to WriterConfig. @angelozerr if you like to try it, you can build your own version from master (mvn clean install) rather than waiting for the release. |
Thanks @ralfstx! I will try it, but I would like to wait the release of minimal-json because our update site is updated each time we push something in our git. |
I want to be able to fix the pretty print to suite my needs and it appears the JsonWriter is package protected. Could this be changed to public so that I can write my own print customizations please? For example, My want to not newline arrays or only indent just the first level items. Being able to fully control would be nice. |
What about having a PrettyPrintConfig (for example!) interface and a default implementation which would allow users to create their own configurations without changing the JsonWriter visibility? I would think it would probably be the sort of complicated class in terms of number of possible settings which would be very amenable to a builder class with methods such as #setIndentString(String indent) which all return the builder to allow daisy-chaining method calls? |
No description provided.
The text was updated successfully, but these errors were encountered: