فهرست منبع

jsonpb: Format and parse the WKTs in wrappers.proto.

Per the spec, they are meant to use the same representation
in JSON as the wrapped primitive type. Fortunately for us,
that is trivial to implement.
David Symonds 10 سال پیش
والد
کامیت
c6184d34b2
5فایلهای تغییر یافته به همراه185 افزوده شده و 56 حذف شده
  1. 13 0
      jsonpb/jsonpb.go
  2. 23 0
      jsonpb/jsonpb_test.go
  3. 1 1
      jsonpb/jsonpb_test_proto/Makefile
  4. 137 55
      jsonpb/jsonpb_test_proto/test_objects.pb.go
  5. 11 0
      jsonpb/jsonpb_test_proto/test_objects.proto

+ 13 - 0
jsonpb/jsonpb.go

@@ -107,6 +107,12 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent string
 	}
 	}
 	if wkt, ok := v.(wkt); ok {
 	if wkt, ok := v.(wkt); ok {
 		switch wkt.XXX_WellKnownType() {
 		switch wkt.XXX_WellKnownType() {
+		case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value",
+			"Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue":
+			// "Wrappers use the same representation in JSON
+			//  as the wrapped primitive type, ..."
+			sprop := proto.GetProperties(s.Type())
+			return m.marshalValue(out, sprop.Prop[0], s.Field(0), indent)
 		case "Duration":
 		case "Duration":
 			// "Generated output always contains 3, 6, or 9 fractional digits,
 			// "Generated output always contains 3, 6, or 9 fractional digits,
 			//  depending on required precision."
 			//  depending on required precision."
@@ -427,6 +433,13 @@ func unmarshalValue(target reflect.Value, inputValue json.RawMessage) error {
 	}
 	}
 	if wkt, ok := target.Addr().Interface().(wkt); ok {
 	if wkt, ok := target.Addr().Interface().(wkt); ok {
 		switch wkt.XXX_WellKnownType() {
 		switch wkt.XXX_WellKnownType() {
+		case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value",
+			"Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue":
+			// "Wrappers use the same representation in JSON
+			//  as the wrapped primitive type, except that null is allowed."
+			// encoding/json will turn JSON `null` into Go `nil`,
+			// so we don't have to do any extra work.
+			return unmarshalValue(target.Field(0), inputValue)
 		case "Duration":
 		case "Duration":
 			unq, err := strconv.Unquote(string(inputValue))
 			unq, err := strconv.Unquote(string(inputValue))
 			if err != nil {
 			if err != nil {

+ 23 - 0
jsonpb/jsonpb_test.go

@@ -41,6 +41,7 @@ import (
 	proto3pb "github.com/golang/protobuf/proto/proto3_proto"
 	proto3pb "github.com/golang/protobuf/proto/proto3_proto"
 	durpb "github.com/golang/protobuf/ptypes/duration"
 	durpb "github.com/golang/protobuf/ptypes/duration"
 	tspb "github.com/golang/protobuf/ptypes/timestamp"
 	tspb "github.com/golang/protobuf/ptypes/timestamp"
+	wpb "github.com/golang/protobuf/ptypes/wrappers"
 )
 )
 
 
 var (
 var (
@@ -321,6 +322,16 @@ var marshalingTests = []struct {
 
 
 	{"Duration", marshaler, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}, `{"dur":"3.000s"}`},
 	{"Duration", marshaler, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}, `{"dur":"3.000s"}`},
 	{"Timestamp", marshaler, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}, `{"ts":"2014-05-13T16:53:20.021Z"}`},
 	{"Timestamp", marshaler, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}, `{"ts":"2014-05-13T16:53:20.021Z"}`},
+
+	{"DoubleValue", marshaler, &pb.KnownTypes{Dbl: &wpb.DoubleValue{Value: 1.2}}, `{"dbl":1.2}`},
+	{"FloatValue", marshaler, &pb.KnownTypes{Flt: &wpb.FloatValue{Value: 1.2}}, `{"flt":1.2}`},
+	{"Int64Value", marshaler, &pb.KnownTypes{I64: &wpb.Int64Value{Value: -3}}, `{"i64":"-3"}`},
+	{"UInt64Value", marshaler, &pb.KnownTypes{U64: &wpb.UInt64Value{Value: 3}}, `{"u64":"3"}`},
+	{"Int32Value", marshaler, &pb.KnownTypes{I32: &wpb.Int32Value{Value: -4}}, `{"i32":-4}`},
+	{"UInt32Value", marshaler, &pb.KnownTypes{U32: &wpb.UInt32Value{Value: 4}}, `{"u32":4}`},
+	{"BoolValue", marshaler, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}, `{"bool":true}`},
+	{"StringValue", marshaler, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}, `{"str":"plush"}`},
+	{"BytesValue", marshaler, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}, `{"bytes":"d293"}`},
 }
 }
 
 
 func TestMarshaling(t *testing.T) {
 func TestMarshaling(t *testing.T) {
@@ -363,6 +374,18 @@ var unmarshalingTests = []struct {
 
 
 	{"Duration", `{"dur":"3.000s"}`, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}},
 	{"Duration", `{"dur":"3.000s"}`, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}},
 	{"Timestamp", `{"ts":"2014-05-13T16:53:20.021Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}},
 	{"Timestamp", `{"ts":"2014-05-13T16:53:20.021Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}},
+
+	{"DoubleValue", `{"dbl":1.2}`, &pb.KnownTypes{Dbl: &wpb.DoubleValue{Value: 1.2}}},
+	{"FloatValue", `{"flt":1.2}`, &pb.KnownTypes{Flt: &wpb.FloatValue{Value: 1.2}}},
+	{"Int64Value", `{"i64":"-3"}`, &pb.KnownTypes{I64: &wpb.Int64Value{Value: -3}}},
+	{"UInt64Value", `{"u64":"3"}`, &pb.KnownTypes{U64: &wpb.UInt64Value{Value: 3}}},
+	{"Int32Value", `{"i32":-4}`, &pb.KnownTypes{I32: &wpb.Int32Value{Value: -4}}},
+	{"UInt32Value", `{"u32":4}`, &pb.KnownTypes{U32: &wpb.UInt32Value{Value: 4}}},
+	{"BoolValue", `{"bool":true}`, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}},
+	{"StringValue", `{"str":"plush"}`, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}},
+	{"BytesValue", `{"bytes":"d293"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}},
+	// `null` is also a permissible value. Let's just test one.
+	{"null DoubleValue", `{"dbl":null}`, &pb.KnownTypes{Dbl: &wpb.DoubleValue{}}},
 }
 }
 
 
 func TestUnmarshaling(t *testing.T) {
 func TestUnmarshaling(t *testing.T) {

+ 1 - 1
jsonpb/jsonpb_test_proto/Makefile

@@ -30,4 +30,4 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 regenerate:
 regenerate:
-	protoc --go_out=Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp:. *.proto
+	protoc --go_out=Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers:. *.proto

+ 137 - 55
jsonpb/jsonpb_test_proto/test_objects.pb.go

@@ -9,6 +9,7 @@ import fmt "fmt"
 import math "math"
 import math "math"
 import google_protobuf "github.com/golang/protobuf/ptypes/duration"
 import google_protobuf "github.com/golang/protobuf/ptypes/duration"
 import google_protobuf1 "github.com/golang/protobuf/ptypes/timestamp"
 import google_protobuf1 "github.com/golang/protobuf/ptypes/timestamp"
+import google_protobuf2 "github.com/golang/protobuf/ptypes/wrappers"
 
 
 // Reference imports to suppress errors if they are not otherwise used.
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
 var _ = proto.Marshal
@@ -517,9 +518,18 @@ var E_Complex_RealExtension = &proto.ExtensionDesc{
 }
 }
 
 
 type KnownTypes struct {
 type KnownTypes struct {
-	Dur              *google_protobuf.Duration   `protobuf:"bytes,1,opt,name=dur" json:"dur,omitempty"`
-	Ts               *google_protobuf1.Timestamp `protobuf:"bytes,2,opt,name=ts" json:"ts,omitempty"`
-	XXX_unrecognized []byte                      `json:"-"`
+	Dur              *google_protobuf.Duration     `protobuf:"bytes,1,opt,name=dur" json:"dur,omitempty"`
+	Ts               *google_protobuf1.Timestamp   `protobuf:"bytes,2,opt,name=ts" json:"ts,omitempty"`
+	Dbl              *google_protobuf2.DoubleValue `protobuf:"bytes,3,opt,name=dbl" json:"dbl,omitempty"`
+	Flt              *google_protobuf2.FloatValue  `protobuf:"bytes,4,opt,name=flt" json:"flt,omitempty"`
+	I64              *google_protobuf2.Int64Value  `protobuf:"bytes,5,opt,name=i64" json:"i64,omitempty"`
+	U64              *google_protobuf2.UInt64Value `protobuf:"bytes,6,opt,name=u64" json:"u64,omitempty"`
+	I32              *google_protobuf2.Int32Value  `protobuf:"bytes,7,opt,name=i32" json:"i32,omitempty"`
+	U32              *google_protobuf2.UInt32Value `protobuf:"bytes,8,opt,name=u32" json:"u32,omitempty"`
+	Bool             *google_protobuf2.BoolValue   `protobuf:"bytes,9,opt,name=bool" json:"bool,omitempty"`
+	Str              *google_protobuf2.StringValue `protobuf:"bytes,10,opt,name=str" json:"str,omitempty"`
+	Bytes            *google_protobuf2.BytesValue  `protobuf:"bytes,11,opt,name=bytes" json:"bytes,omitempty"`
+	XXX_unrecognized []byte                        `json:"-"`
 }
 }
 
 
 func (m *KnownTypes) Reset()                    { *m = KnownTypes{} }
 func (m *KnownTypes) Reset()                    { *m = KnownTypes{} }
@@ -541,6 +551,69 @@ func (m *KnownTypes) GetTs() *google_protobuf1.Timestamp {
 	return nil
 	return nil
 }
 }
 
 
+func (m *KnownTypes) GetDbl() *google_protobuf2.DoubleValue {
+	if m != nil {
+		return m.Dbl
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetFlt() *google_protobuf2.FloatValue {
+	if m != nil {
+		return m.Flt
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetI64() *google_protobuf2.Int64Value {
+	if m != nil {
+		return m.I64
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetU64() *google_protobuf2.UInt64Value {
+	if m != nil {
+		return m.U64
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetI32() *google_protobuf2.Int32Value {
+	if m != nil {
+		return m.I32
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetU32() *google_protobuf2.UInt32Value {
+	if m != nil {
+		return m.U32
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetBool() *google_protobuf2.BoolValue {
+	if m != nil {
+		return m.Bool
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetStr() *google_protobuf2.StringValue {
+	if m != nil {
+		return m.Str
+	}
+	return nil
+}
+
+func (m *KnownTypes) GetBytes() *google_protobuf2.BytesValue {
+	if m != nil {
+		return m.Bytes
+	}
+	return nil
+}
+
 var E_Name = &proto.ExtensionDesc{
 var E_Name = &proto.ExtensionDesc{
 	ExtendedType:  (*Real)(nil),
 	ExtendedType:  (*Real)(nil),
 	ExtensionType: (*string)(nil),
 	ExtensionType: (*string)(nil),
@@ -564,56 +637,65 @@ func init() {
 }
 }
 
 
 var fileDescriptor1 = []byte{
 var fileDescriptor1 = []byte{
-	// 812 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x94, 0xdf, 0x8e, 0xdb, 0x44,
-	0x14, 0xc6, 0x1b, 0x4f, 0x9c, 0xd8, 0x27, 0xbb, 0x4b, 0x18, 0x6d, 0xc1, 0x0d, 0xff, 0x2a, 0x0b,
-	0x2a, 0x28, 0xe0, 0x4a, 0xa1, 0xaa, 0x50, 0xe1, 0x86, 0xed, 0x06, 0xa8, 0x60, 0x8b, 0x34, 0xdb,
-	0xaa, 0x97, 0x91, 0xd3, 0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c, 0x3a, 0x9a, 0xb3, 0x6b, 0xbd, 0x4f, 0xbb, 0xad, 0x2f, 0xa8,
-	0xeb, 0xe1, 0x6d, 0x18, 0xd6, 0x79, 0x25, 0xaf, 0x1c, 0xf1, 0x4f, 0x7b, 0x93, 0x56, 0xf9, 0x3f,
-	0x00, 0x00, 0xff, 0xff, 0x73, 0x4f, 0x6f, 0xec, 0x73, 0x06, 0x00, 0x00,
+	// 947 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x7c, 0x95, 0xd1, 0x72, 0xdb, 0x44,
+	0x14, 0x86, 0x6b, 0xad, 0x65, 0x49, 0xeb, 0x26, 0x98, 0x9d, 0x14, 0x54, 0x53, 0xa0, 0xe3, 0x81,
+	0x0e, 0x14, 0x50, 0x07, 0xb7, 0xd3, 0x61, 0x0a, 0x37, 0xa4, 0x31, 0xd0, 0x81, 0x94, 0x99, 0x4d,
+	0x43, 0x2f, 0x3d, 0x72, 0xa3, 0x18, 0x15, 0x49, 0xab, 0x39, 0x92, 0x49, 0x3d, 0x70, 0xc1, 0x43,
+	0xc0, 0x23, 0xc0, 0x23, 0xf0, 0x7c, 0x9c, 0xb3, 0x2b, 0x69, 0x9d, 0xb8, 0x26, 0x37, 0xf1, 0xea,
+	0xff, 0xcf, 0xaf, 0xd5, 0xb7, 0x47, 0x47, 0x5c, 0xd4, 0x49, 0x55, 0xcf, 0xd5, 0xe2, 0x65, 0xf2,
+	0xa2, 0xae, 0xa2, 0x12, 0x54, 0xad, 0xc4, 0xe0, 0x65, 0xa5, 0x8a, 0x72, 0x31, 0x7e, 0x6f, 0xa9,
+	0xd4, 0x32, 0x4b, 0xee, 0xe9, 0xab, 0x8b, 0xd5, 0xf9, 0xbd, 0xb3, 0x15, 0xc4, 0x75, 0xaa, 0x0a,
+	0xe3, 0x1b, 0xbf, 0x7f, 0x55, 0xaf, 0xd3, 0x1c, 0xd3, 0xe2, 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, 0xc7, 0xd1, 0xe7, 0xed,
+	0x8e, 0xbf, 0x3f, 0x6d, 0xe3, 0x71, 0x26, 0x52, 0x3c, 0xda, 0xfd, 0xff, 0x89, 0xef, 0xfc, 0x2b,
+	0xed, 0xef, 0xeb, 0xd9, 0x1e, 0xec, 0x40, 0x49, 0xcd, 0x6d, 0xec, 0xda, 0x47, 0xf9, 0xf4, 0x9a,
+	0xf2, 0x1d, 0xf9, 0x66, 0x5e, 0x36, 0xf9, 0x68, 0x14, 0x9f, 0x73, 0xd7, 0x7e, 0x60, 0x5e, 0xf7,
+	0x00, 0x7a, 0x8e, 0x9a, 0x02, 0xe3, 0x7c, 0x74, 0x9b, 0xf7, 0x8b, 0x38, 0x4f, 0xae, 0xf4, 0xd4,
+	0xef, 0xfa, 0xd5, 0xd3, 0xca, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa1, 0xac, 0xb6, 0x4e, 0x44,
+	0x08, 0x00, 0x00,
 }
 }

+ 11 - 0
jsonpb/jsonpb_test_proto/test_objects.proto

@@ -33,6 +33,7 @@ syntax = "proto2";
 
 
 import "google/protobuf/duration.proto";
 import "google/protobuf/duration.proto";
 import "google/protobuf/timestamp.proto";
 import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
 
 
 package jsonpb;
 package jsonpb;
 
 
@@ -115,4 +116,14 @@ message Complex {
 message KnownTypes {
 message KnownTypes {
   optional google.protobuf.Duration dur = 1;
   optional google.protobuf.Duration dur = 1;
   optional google.protobuf.Timestamp ts = 2;
   optional google.protobuf.Timestamp ts = 2;
+
+  optional google.protobuf.DoubleValue dbl = 3;
+  optional google.protobuf.FloatValue flt = 4;
+  optional google.protobuf.Int64Value i64 = 5;
+  optional google.protobuf.UInt64Value u64 = 6;
+  optional google.protobuf.Int32Value i32 = 7;
+  optional google.protobuf.UInt32Value u32 = 8;
+  optional google.protobuf.BoolValue bool = 9;
+  optional google.protobuf.StringValue str = 10;
+  optional google.protobuf.BytesValue bytes = 11;
 }
 }