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

JSON output lacks add_whitespace and always_print_primitive_fields #1171

Open
jiawen opened this issue Sep 14, 2021 · 3 comments
Open

JSON output lacks add_whitespace and always_print_primitive_fields #1171

jiawen opened this issue Sep 14, 2021 · 3 comments

Comments

@jiawen
Copy link

jiawen commented Sep 14, 2021

My projects serializes proto3 messages to JSON as a nice human-readable format that also allows for some light editing. However, the current Swift output is very hard to read, as everything is on one line.

The C++ API has add_whitespace and always_print_primitive_fields options that the Swift version lacks.

It seems reasonably easy to add and test.

@tbkka
Copy link
Contributor

tbkka commented Sep 14, 2021

Reformatting JSON is pretty easy to do. For example, you can easily invoke JSONSerialization from Swift Foundation to deserialize arbitrary JSON and re-serialize in a prettier format. So I'm not convinced we need to add pretty-printing to our JSON encoder.
I'm not as familiar with always_print_primitive_fields; that might be an appropriate addition.

@jiawen
Copy link
Author

jiawen commented Sep 15, 2021

Makes sense. TIL JSONSerialization.

@open-meteo
Copy link

The idea behind always_print_primitive_fields is also discussed here #861. I would also appreciate to have this option!

Best, Jeff

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

3 participants