-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(bigtable): Add MarshalJSON to allow clients to get a stringified version of the protobuf #10679
Conversation
…ion of the protobuf
bigtable/type_test.go
Outdated
if !proto.Equal(got, want) { | ||
t.Errorf("got type %v, want: %v", got, want) | ||
wantJSON := "{\"stringType\":{\"encoding\":{\"utf8Raw\":{}}}}" | ||
if strings.ReplaceAll(string(gotJSON), " ", "") != wantJSON { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than testing that the json equals a known string, I think we can instead just test that round tripping the object from json and back yield the "correct" thing? Comparing json strings has the potential for false errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bigtable/type.go
Outdated
|
||
// Type wraps the protobuf representation of a type. See the protobuf definition | ||
// for more details on types. | ||
type Type interface { | ||
proto() *btapb.Type | ||
} | ||
|
||
var marshalOptions = protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} | ||
var unmarshalOptions = protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we want DiscardUnknown? assuming that does what it sounds like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.