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

feat: format JSON output to stabilize its output #64

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

radhus
Copy link
Member

@radhus radhus commented Aug 1, 2022

protojson doesn't guarantee stable JSON output, and deliberately
introduce minor differences in output to prevent the illusion of this,
see 1.

As this tool generates code, we'd like to keep the output as stable as
possible, use the advice in 1 and 2 (at the end) and run the
generated JSON through a formatter before including it in the generated
code. This also changes from using the error ignoring Format() function
to Marshal().

protojson doesn't guarantee stable JSON output, and deliberately
introduce minor differences in output to prevent the illusion of this,
see [1].

As this tool generates code, we'd like to keep the output as stable as
possible, use the advice in [1] and [2] (at the end) and run the
generated JSON through a formatter before including it in the generated
code. This also changes from using the error ignoring Format() function
to Marshal().

[1]: https://developers.google.com/protocol-buffers/docs/reference/go/faq#unstable-json
[2]: golang/protobuf#1121 (comment)
@radhus radhus requested review from odsod and ericwenn as code owners August 1, 2022 14:04
@radhus radhus merged commit 8de6957 into master Aug 2, 2022
@radhus radhus deleted the stabilize-json-output branch August 2, 2022 06:28
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

Successfully merging this pull request may close these issues.

2 participants