Ruby JSON serialization seems to be incompatible when using Well-Known types.
For example, I'm using google.protobuf.Timestamp.
It expects to be mapped RFC3339 string. However, ruby binding encodes it to be object.
Google::Protobuf::Timestamp.new(seconds: Time.current.to_i, nanos: Time.current.nsec).to_json
=> "{\"seconds\":1524627489,\"nanos\":820635000}"
syntax = "proto3";
package proto.foo;
import "google/protobuf/timestamp.proto";
@option java_outer_classname = "Protobuf";
message Record {
google.protobuf.Timestamp created_at = 1;
google.protobuf.Timestamp updated_at = 2;
}
Proto::Foo::Record.new(
created_at: Google::Protobuf::Timestamp(seconds: created_at.to_i, nanos: created_at.nsec),
updated_at: Google::Protobuf::Timestamp(seconds: updated_at.to_i, nanos: updated_at.nsec)
).to_json
Protobuf.Record.Builder builder = Protobuf.Record.newBuilder();
JsonFormat.parser().merge(json, builder);
// => com.google.protobuf.InvalidProtocolBufferException
ruby hasn't passed conformance test yet. This will be fixed.
Most of well known type issue in json have been fixed.
There are still some edge cases broken. See conformance/failure_list_ruby.txt for details.
Most helpful comment
ruby hasn't passed conformance test yet. This will be fixed.