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(json): add runtime-agnostic ability to write messages to JSON #31

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

dylan-bourque
Copy link
Collaborator

adds new MarshalJSON() function to generated formatted JSON output for a message

Resolves #9

@dylan-bourque
Copy link
Collaborator Author

cc @florinrm

@dylan-bourque
Copy link
Collaborator Author

Reworked this code to instead use a wrapper type that satisfies json.Marshaler and a set of functional options. The primary motivation was to make the default usage simpler.

result, err := csproto.JSONMarshaler(msg).MarshalJSON()

vs

result, err := csproto.MarshalJSON(msg, csproto.JSONOptions{})

adds a new `JSONMarshaler(msg interface{}, opts ...JSONOption)` function
for converting a proto message to JSON with optional extended formatting

Issue: #9

reworked JSON marshaling support
@dylan-bourque dylan-bourque merged commit 54904f1 into main Apr 22, 2022
@dylan-bourque dylan-bourque deleted the feat/add-json-marshal branch April 22, 2022 20:18
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.

No runtime-agnostic API for JSON marshaling
2 participants