googleapis/gapic-showcase

Add well-known types as fields in the compliance service

vchudnov-g opened this issue · 2 comments

Well known types are listed in https://developers.google.com/protocol-buffers/docs/reference/google.protobuf, and their JSON representations are summarized in the bottom part of this table.

We should have well-known types whose JSON representation is a string be fields in compliance.proto's ComplianceData to ensure clients serialize/deserialize them correctly.

Yup, I've just fixed a bug in .NET's transcoding due to this.

We should have well-known types whose JSON representation is a string

More than that, I think - I'd expect all of BoolValue, Int32Value, Int64Value, UInt32Value, UInt64Value, SingleValue and DoubleValue to have tests. The 64-bit integer and floating point types are particularly tricky, as they can appear in JSON as either strings or numbers. (For floating point, "Infinity", "-Infinity", "NaN" are all represented as strings; others are numbers. 64-bit integers can be represented as numbers, but only as far as 2^53 after which they have to be represented as strings in order to avoid a loss of precision.)

I'm adding this to the unit test conformance data we use in .NET, and which I hope to move to the conformance-tests repo soon. Having it in Showcase as well would be good though :)

One tricky aspect of StringValue: the JSON representation would escape some characters, where we presumably don't want to. For example, a value of \ (backslash) is "\\" in JSON, and I suspect we need to make sure that we don't have those double backslashes.