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

Add message option to serialize as well known JSON type #739

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martindam
Copy link

@martindam martindam commented Oct 21, 2021

This is a suggested implementation of #738

With this diff it is possible to mark that a message should be JSON marshalled as a well known type

Without jsonwkt option:

message UUID {
	string value = 1;
}
message MyType {
	UUID user_uuid = 1;
}

MyType would be serialized to JSON as:

{
	"user_uuid": {
		"value": "8dfab8c2-7916-477f-bbd6-c9fc00dc4158"
	}
}

With jsonwkt option

message UUID {
	option (gogoproto.json_well_known_type) = "StringValue";
	string value = 1;
}
message MyType {
	UUID user_uuid = 1;
}

MyType would be serialized to JSON as:

{
	"user_uuid": "8dfab8c2-7916-477f-bbd6-c9fc00dc4158"
}

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.

1 participant