summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/golang/protobuf/jsonpb
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-11-22 11:05:54 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-22 14:05:54 -0500
commit7961599b2e41c71720a42b3bfde641f7529f05fe (patch)
tree3c039e1d3790a954ba65fe551c7b348331bce994 /vendor/github.com/golang/protobuf/jsonpb
parente033dcce8e57ed6b6684227adf9b29347e4718b3 (diff)
downloadchat-7961599b2e41c71720a42b3bfde641f7529f05fe.tar.gz
chat-7961599b2e41c71720a42b3bfde641f7529f05fe.tar.bz2
chat-7961599b2e41c71720a42b3bfde641f7529f05fe.zip
PLT-4357 adding performance monitoring (#4622)
* WIP * WIP * Adding metrics collection * updating vendor packages * Adding metrics to config * Adding admin console page for perf monitoring * Updating glide * switching to tylerb/graceful
Diffstat (limited to 'vendor/github.com/golang/protobuf/jsonpb')
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb.go843
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go563
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile33
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go207
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto57
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go771
-rw-r--r--vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto135
7 files changed, 2609 insertions, 0 deletions
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go
new file mode 100644
index 000000000..82c61624e
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go
@@ -0,0 +1,843 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2015 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/*
+Package jsonpb provides marshaling and unmarshaling between protocol buffers and JSON.
+It follows the specification at https://developers.google.com/protocol-buffers/docs/proto3#json.
+
+This package produces a different output than the standard "encoding/json" package,
+which does not operate correctly on protocol buffers.
+*/
+package jsonpb
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "reflect"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/golang/protobuf/proto"
+)
+
+// Marshaler is a configurable object for converting between
+// protocol buffer objects and a JSON representation for them.
+type Marshaler struct {
+ // Whether to render enum values as integers, as opposed to string values.
+ EnumsAsInts bool
+
+ // Whether to render fields with zero values.
+ EmitDefaults bool
+
+ // A string to indent each level by. The presence of this field will
+ // also cause a space to appear between the field separator and
+ // value, and for newlines to be appear between fields and array
+ // elements.
+ Indent string
+
+ // Whether to use the original (.proto) name for fields.
+ OrigName bool
+}
+
+// Marshal marshals a protocol buffer into JSON.
+func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error {
+ writer := &errWriter{writer: out}
+ return m.marshalObject(writer, pb, "", "")
+}
+
+// MarshalToString converts a protocol buffer object to JSON string.
+func (m *Marshaler) MarshalToString(pb proto.Message) (string, error) {
+ var buf bytes.Buffer
+ if err := m.Marshal(&buf, pb); err != nil {
+ return "", err
+ }
+ return buf.String(), nil
+}
+
+type int32Slice []int32
+
+// For sorting extensions ids to ensure stable output.
+func (s int32Slice) Len() int { return len(s) }
+func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] }
+func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+
+type wkt interface {
+ XXX_WellKnownType() string
+}
+
+// marshalObject writes a struct to the Writer.
+func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error {
+ s := reflect.ValueOf(v).Elem()
+
+ // Handle well-known types.
+ if wkt, ok := v.(wkt); ok {
+ 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 "Any":
+ // Any is a bit more involved.
+ return m.marshalAny(out, v, indent)
+ case "Duration":
+ // "Generated output always contains 3, 6, or 9 fractional digits,
+ // depending on required precision."
+ s, ns := s.Field(0).Int(), s.Field(1).Int()
+ d := time.Duration(s)*time.Second + time.Duration(ns)*time.Nanosecond
+ x := fmt.Sprintf("%.9f", d.Seconds())
+ x = strings.TrimSuffix(x, "000")
+ x = strings.TrimSuffix(x, "000")
+ out.write(`"`)
+ out.write(x)
+ out.write(`s"`)
+ return out.err
+ case "Struct":
+ // Let marshalValue handle the `fields` map.
+ // TODO: pass the correct Properties if needed.
+ return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent)
+ case "Timestamp":
+ // "RFC 3339, where generated output will always be Z-normalized
+ // and uses 3, 6 or 9 fractional digits."
+ s, ns := s.Field(0).Int(), s.Field(1).Int()
+ t := time.Unix(s, ns).UTC()
+ // time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits).
+ x := t.Format("2006-01-02T15:04:05.000000000")
+ x = strings.TrimSuffix(x, "000")
+ x = strings.TrimSuffix(x, "000")
+ out.write(`"`)
+ out.write(x)
+ out.write(`Z"`)
+ return out.err
+ case "Value":
+ // Value has a single oneof.
+ kind := s.Field(0)
+ if kind.IsNil() {
+ // "absence of any variant indicates an error"
+ return errors.New("nil Value")
+ }
+ // oneof -> *T -> T -> T.F
+ x := kind.Elem().Elem().Field(0)
+ // TODO: pass the correct Properties if needed.
+ return m.marshalValue(out, &proto.Properties{}, x, indent)
+ }
+ }
+
+ out.write("{")
+ if m.Indent != "" {
+ out.write("\n")
+ }
+
+ firstField := true
+
+ if typeURL != "" {
+ if err := m.marshalTypeURL(out, indent, typeURL); err != nil {
+ return err
+ }
+ firstField = false
+ }
+
+ for i := 0; i < s.NumField(); i++ {
+ value := s.Field(i)
+ valueField := s.Type().Field(i)
+ if strings.HasPrefix(valueField.Name, "XXX_") {
+ continue
+ }
+
+ // IsNil will panic on most value kinds.
+ switch value.Kind() {
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ if value.IsNil() {
+ continue
+ }
+ }
+
+ if !m.EmitDefaults {
+ switch value.Kind() {
+ case reflect.Bool:
+ if !value.Bool() {
+ continue
+ }
+ case reflect.Int32, reflect.Int64:
+ if value.Int() == 0 {
+ continue
+ }
+ case reflect.Uint32, reflect.Uint64:
+ if value.Uint() == 0 {
+ continue
+ }
+ case reflect.Float32, reflect.Float64:
+ if value.Float() == 0 {
+ continue
+ }
+ case reflect.String:
+ if value.Len() == 0 {
+ continue
+ }
+ }
+ }
+
+ // Oneof fields need special handling.
+ if valueField.Tag.Get("protobuf_oneof") != "" {
+ // value is an interface containing &T{real_value}.
+ sv := value.Elem().Elem() // interface -> *T -> T
+ value = sv.Field(0)
+ valueField = sv.Type().Field(0)
+ }
+ prop := jsonProperties(valueField, m.OrigName)
+ if !firstField {
+ m.writeSep(out)
+ }
+ if err := m.marshalField(out, prop, value, indent); err != nil {
+ return err
+ }
+ firstField = false
+ }
+
+ // Handle proto2 extensions.
+ if ep, ok := v.(proto.Message); ok {
+ extensions := proto.RegisteredExtensions(v)
+ // Sort extensions for stable output.
+ ids := make([]int32, 0, len(extensions))
+ for id, desc := range extensions {
+ if !proto.HasExtension(ep, desc) {
+ continue
+ }
+ ids = append(ids, id)
+ }
+ sort.Sort(int32Slice(ids))
+ for _, id := range ids {
+ desc := extensions[id]
+ if desc == nil {
+ // unknown extension
+ continue
+ }
+ ext, extErr := proto.GetExtension(ep, desc)
+ if extErr != nil {
+ return extErr
+ }
+ value := reflect.ValueOf(ext)
+ var prop proto.Properties
+ prop.Parse(desc.Tag)
+ prop.JSONName = fmt.Sprintf("[%s]", desc.Name)
+ if !firstField {
+ m.writeSep(out)
+ }
+ if err := m.marshalField(out, &prop, value, indent); err != nil {
+ return err
+ }
+ firstField = false
+ }
+
+ }
+
+ if m.Indent != "" {
+ out.write("\n")
+ out.write(indent)
+ }
+ out.write("}")
+ return out.err
+}
+
+func (m *Marshaler) writeSep(out *errWriter) {
+ if m.Indent != "" {
+ out.write(",\n")
+ } else {
+ out.write(",")
+ }
+}
+
+func (m *Marshaler) marshalAny(out *errWriter, any proto.Message, indent string) error {
+ // "If the Any contains a value that has a special JSON mapping,
+ // it will be converted as follows: {"@type": xxx, "value": yyy}.
+ // Otherwise, the value will be converted into a JSON object,
+ // and the "@type" field will be inserted to indicate the actual data type."
+ v := reflect.ValueOf(any).Elem()
+ turl := v.Field(0).String()
+ val := v.Field(1).Bytes()
+
+ // Only the part of type_url after the last slash is relevant.
+ mname := turl
+ if slash := strings.LastIndex(mname, "/"); slash >= 0 {
+ mname = mname[slash+1:]
+ }
+ mt := proto.MessageType(mname)
+ if mt == nil {
+ return fmt.Errorf("unknown message type %q", mname)
+ }
+ msg := reflect.New(mt.Elem()).Interface().(proto.Message)
+ if err := proto.Unmarshal(val, msg); err != nil {
+ return err
+ }
+
+ if _, ok := msg.(wkt); ok {
+ out.write("{")
+ if m.Indent != "" {
+ out.write("\n")
+ }
+ if err := m.marshalTypeURL(out, indent, turl); err != nil {
+ return err
+ }
+ m.writeSep(out)
+ if m.Indent != "" {
+ out.write(indent)
+ out.write(m.Indent)
+ out.write(`"value": `)
+ } else {
+ out.write(`"value":`)
+ }
+ if err := m.marshalObject(out, msg, indent+m.Indent, ""); err != nil {
+ return err
+ }
+ if m.Indent != "" {
+ out.write("\n")
+ out.write(indent)
+ }
+ out.write("}")
+ return out.err
+ }
+
+ return m.marshalObject(out, msg, indent, turl)
+}
+
+func (m *Marshaler) marshalTypeURL(out *errWriter, indent, typeURL string) error {
+ if m.Indent != "" {
+ out.write(indent)
+ out.write(m.Indent)
+ }
+ out.write(`"@type":`)
+ if m.Indent != "" {
+ out.write(" ")
+ }
+ b, err := json.Marshal(typeURL)
+ if err != nil {
+ return err
+ }
+ out.write(string(b))
+ return out.err
+}
+
+// marshalField writes field description and value to the Writer.
+func (m *Marshaler) marshalField(out *errWriter, prop *proto.Properties, v reflect.Value, indent string) error {
+ if m.Indent != "" {
+ out.write(indent)
+ out.write(m.Indent)
+ }
+ out.write(`"`)
+ out.write(prop.JSONName)
+ out.write(`":`)
+ if m.Indent != "" {
+ out.write(" ")
+ }
+ if err := m.marshalValue(out, prop, v, indent); err != nil {
+ return err
+ }
+ return nil
+}
+
+// marshalValue writes the value to the Writer.
+func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v reflect.Value, indent string) error {
+
+ var err error
+ v = reflect.Indirect(v)
+
+ // Handle repeated elements.
+ if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 {
+ out.write("[")
+ comma := ""
+ for i := 0; i < v.Len(); i++ {
+ sliceVal := v.Index(i)
+ out.write(comma)
+ if m.Indent != "" {
+ out.write("\n")
+ out.write(indent)
+ out.write(m.Indent)
+ out.write(m.Indent)
+ }
+ if err := m.marshalValue(out, prop, sliceVal, indent+m.Indent); err != nil {
+ return err
+ }
+ comma = ","
+ }
+ if m.Indent != "" {
+ out.write("\n")
+ out.write(indent)
+ out.write(m.Indent)
+ }
+ out.write("]")
+ return out.err
+ }
+
+ // Handle well-known types.
+ // Most are handled up in marshalObject (because 99% are messages).
+ type wkt interface {
+ XXX_WellKnownType() string
+ }
+ if wkt, ok := v.Interface().(wkt); ok {
+ switch wkt.XXX_WellKnownType() {
+ case "NullValue":
+ out.write("null")
+ return out.err
+ }
+ }
+
+ // Handle enumerations.
+ if !m.EnumsAsInts && prop.Enum != "" {
+ // Unknown enum values will are stringified by the proto library as their
+ // value. Such values should _not_ be quoted or they will be interpreted
+ // as an enum string instead of their value.
+ enumStr := v.Interface().(fmt.Stringer).String()
+ var valStr string
+ if v.Kind() == reflect.Ptr {
+ valStr = strconv.Itoa(int(v.Elem().Int()))
+ } else {
+ valStr = strconv.Itoa(int(v.Int()))
+ }
+ isKnownEnum := enumStr != valStr
+ if isKnownEnum {
+ out.write(`"`)
+ }
+ out.write(enumStr)
+ if isKnownEnum {
+ out.write(`"`)
+ }
+ return out.err
+ }
+
+ // Handle nested messages.
+ if v.Kind() == reflect.Struct {
+ return m.marshalObject(out, v.Addr().Interface().(proto.Message), indent+m.Indent, "")
+ }
+
+ // Handle maps.
+ // Since Go randomizes map iteration, we sort keys for stable output.
+ if v.Kind() == reflect.Map {
+ out.write(`{`)
+ keys := v.MapKeys()
+ sort.Sort(mapKeys(keys))
+ for i, k := range keys {
+ if i > 0 {
+ out.write(`,`)
+ }
+ if m.Indent != "" {
+ out.write("\n")
+ out.write(indent)
+ out.write(m.Indent)
+ out.write(m.Indent)
+ }
+
+ b, err := json.Marshal(k.Interface())
+ if err != nil {
+ return err
+ }
+ s := string(b)
+
+ // If the JSON is not a string value, encode it again to make it one.
+ if !strings.HasPrefix(s, `"`) {
+ b, err := json.Marshal(s)
+ if err != nil {
+ return err
+ }
+ s = string(b)
+ }
+
+ out.write(s)
+ out.write(`:`)
+ if m.Indent != "" {
+ out.write(` `)
+ }
+
+ if err := m.marshalValue(out, prop, v.MapIndex(k), indent+m.Indent); err != nil {
+ return err
+ }
+ }
+ if m.Indent != "" {
+ out.write("\n")
+ out.write(indent)
+ out.write(m.Indent)
+ }
+ out.write(`}`)
+ return out.err
+ }
+
+ // Default handling defers to the encoding/json library.
+ b, err := json.Marshal(v.Interface())
+ if err != nil {
+ return err
+ }
+ needToQuote := string(b[0]) != `"` && (v.Kind() == reflect.Int64 || v.Kind() == reflect.Uint64)
+ if needToQuote {
+ out.write(`"`)
+ }
+ out.write(string(b))
+ if needToQuote {
+ out.write(`"`)
+ }
+ return out.err
+}
+
+// Unmarshaler is a configurable object for converting from a JSON
+// representation to a protocol buffer object.
+type Unmarshaler struct {
+ // Whether to allow messages to contain unknown fields, as opposed to
+ // failing to unmarshal.
+ AllowUnknownFields bool
+}
+
+// UnmarshalNext unmarshals the next protocol buffer from a JSON object stream.
+// This function is lenient and will decode any options permutations of the
+// related Marshaler.
+func (u *Unmarshaler) UnmarshalNext(dec *json.Decoder, pb proto.Message) error {
+ inputValue := json.RawMessage{}
+ if err := dec.Decode(&inputValue); err != nil {
+ return err
+ }
+ return u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil)
+}
+
+// Unmarshal unmarshals a JSON object stream into a protocol
+// buffer. This function is lenient and will decode any options
+// permutations of the related Marshaler.
+func (u *Unmarshaler) Unmarshal(r io.Reader, pb proto.Message) error {
+ dec := json.NewDecoder(r)
+ return u.UnmarshalNext(dec, pb)
+}
+
+// UnmarshalNext unmarshals the next protocol buffer from a JSON object stream.
+// This function is lenient and will decode any options permutations of the
+// related Marshaler.
+func UnmarshalNext(dec *json.Decoder, pb proto.Message) error {
+ return new(Unmarshaler).UnmarshalNext(dec, pb)
+}
+
+// Unmarshal unmarshals a JSON object stream into a protocol
+// buffer. This function is lenient and will decode any options
+// permutations of the related Marshaler.
+func Unmarshal(r io.Reader, pb proto.Message) error {
+ return new(Unmarshaler).Unmarshal(r, pb)
+}
+
+// UnmarshalString will populate the fields of a protocol buffer based
+// on a JSON string. This function is lenient and will decode any options
+// permutations of the related Marshaler.
+func UnmarshalString(str string, pb proto.Message) error {
+ return new(Unmarshaler).Unmarshal(strings.NewReader(str), pb)
+}
+
+// unmarshalValue converts/copies a value into the target.
+// prop may be nil.
+func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMessage, prop *proto.Properties) error {
+ targetType := target.Type()
+
+ // Allocate memory for pointer fields.
+ if targetType.Kind() == reflect.Ptr {
+ target.Set(reflect.New(targetType.Elem()))
+ return u.unmarshalValue(target.Elem(), inputValue, prop)
+ }
+
+ // Handle well-known types.
+ type wkt interface {
+ XXX_WellKnownType() string
+ }
+ if wkt, ok := target.Addr().Interface().(wkt); ok {
+ 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 u.unmarshalValue(target.Field(0), inputValue, prop)
+ case "Any":
+ return fmt.Errorf("unmarshaling Any not supported yet")
+ case "Duration":
+ ivStr := string(inputValue)
+ if ivStr == "null" {
+ target.Field(0).SetInt(0)
+ target.Field(1).SetInt(0)
+ return nil
+ }
+
+ unq, err := strconv.Unquote(ivStr)
+ if err != nil {
+ return err
+ }
+ d, err := time.ParseDuration(unq)
+ if err != nil {
+ return fmt.Errorf("bad Duration: %v", err)
+ }
+ ns := d.Nanoseconds()
+ s := ns / 1e9
+ ns %= 1e9
+ target.Field(0).SetInt(s)
+ target.Field(1).SetInt(ns)
+ return nil
+ case "Timestamp":
+ ivStr := string(inputValue)
+ if ivStr == "null" {
+ target.Field(0).SetInt(0)
+ target.Field(1).SetInt(0)
+ return nil
+ }
+
+ unq, err := strconv.Unquote(ivStr)
+ if err != nil {
+ return err
+ }
+ t, err := time.Parse(time.RFC3339Nano, unq)
+ if err != nil {
+ return fmt.Errorf("bad Timestamp: %v", err)
+ }
+ target.Field(0).SetInt(int64(t.Unix()))
+ target.Field(1).SetInt(int64(t.Nanosecond()))
+ return nil
+ }
+ }
+
+ // Handle enums, which have an underlying type of int32,
+ // and may appear as strings.
+ // The case of an enum appearing as a number is handled
+ // at the bottom of this function.
+ if inputValue[0] == '"' && prop != nil && prop.Enum != "" {
+ vmap := proto.EnumValueMap(prop.Enum)
+ // Don't need to do unquoting; valid enum names
+ // are from a limited character set.
+ s := inputValue[1 : len(inputValue)-1]
+ n, ok := vmap[string(s)]
+ if !ok {
+ return fmt.Errorf("unknown value %q for enum %s", s, prop.Enum)
+ }
+ if target.Kind() == reflect.Ptr { // proto2
+ target.Set(reflect.New(targetType.Elem()))
+ target = target.Elem()
+ }
+ target.SetInt(int64(n))
+ return nil
+ }
+
+ // Handle nested messages.
+ if targetType.Kind() == reflect.Struct {
+ var jsonFields map[string]json.RawMessage
+ if err := json.Unmarshal(inputValue, &jsonFields); err != nil {
+ return err
+ }
+
+ consumeField := func(prop *proto.Properties) (json.RawMessage, bool) {
+ // Be liberal in what names we accept; both orig_name and camelName are okay.
+ fieldNames := acceptedJSONFieldNames(prop)
+
+ vOrig, okOrig := jsonFields[fieldNames.orig]
+ vCamel, okCamel := jsonFields[fieldNames.camel]
+ if !okOrig && !okCamel {
+ return nil, false
+ }
+ // If, for some reason, both are present in the data, favour the camelName.
+ var raw json.RawMessage
+ if okOrig {
+ raw = vOrig
+ delete(jsonFields, fieldNames.orig)
+ }
+ if okCamel {
+ raw = vCamel
+ delete(jsonFields, fieldNames.camel)
+ }
+ return raw, true
+ }
+
+ sprops := proto.GetProperties(targetType)
+ for i := 0; i < target.NumField(); i++ {
+ ft := target.Type().Field(i)
+ if strings.HasPrefix(ft.Name, "XXX_") {
+ continue
+ }
+
+ valueForField, ok := consumeField(sprops.Prop[i])
+ if !ok {
+ continue
+ }
+
+ if err := u.unmarshalValue(target.Field(i), valueForField, sprops.Prop[i]); err != nil {
+ return err
+ }
+ }
+ // Check for any oneof fields.
+ if len(jsonFields) > 0 {
+ for _, oop := range sprops.OneofTypes {
+ raw, ok := consumeField(oop.Prop)
+ if !ok {
+ continue
+ }
+ nv := reflect.New(oop.Type.Elem())
+ target.Field(oop.Field).Set(nv)
+ if err := u.unmarshalValue(nv.Elem().Field(0), raw, oop.Prop); err != nil {
+ return err
+ }
+ }
+ }
+ if !u.AllowUnknownFields && len(jsonFields) > 0 {
+ // Pick any field to be the scapegoat.
+ var f string
+ for fname := range jsonFields {
+ f = fname
+ break
+ }
+ return fmt.Errorf("unknown field %q in %v", f, targetType)
+ }
+ return nil
+ }
+
+ // Handle arrays (which aren't encoded bytes)
+ if targetType.Kind() == reflect.Slice && targetType.Elem().Kind() != reflect.Uint8 {
+ var slc []json.RawMessage
+ if err := json.Unmarshal(inputValue, &slc); err != nil {
+ return err
+ }
+ len := len(slc)
+ target.Set(reflect.MakeSlice(targetType, len, len))
+ for i := 0; i < len; i++ {
+ if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
+
+ // Handle maps (whose keys are always strings)
+ if targetType.Kind() == reflect.Map {
+ var mp map[string]json.RawMessage
+ if err := json.Unmarshal(inputValue, &mp); err != nil {
+ return err
+ }
+ target.Set(reflect.MakeMap(targetType))
+ var keyprop, valprop *proto.Properties
+ if prop != nil {
+ // These could still be nil if the protobuf metadata is broken somehow.
+ // TODO: This won't work because the fields are unexported.
+ // We should probably just reparse them.
+ //keyprop, valprop = prop.mkeyprop, prop.mvalprop
+ }
+ for ks, raw := range mp {
+ // Unmarshal map key. The core json library already decoded the key into a
+ // string, so we handle that specially. Other types were quoted post-serialization.
+ var k reflect.Value
+ if targetType.Key().Kind() == reflect.String {
+ k = reflect.ValueOf(ks)
+ } else {
+ k = reflect.New(targetType.Key()).Elem()
+ if err := u.unmarshalValue(k, json.RawMessage(ks), keyprop); err != nil {
+ return err
+ }
+ }
+
+ // Unmarshal map value.
+ v := reflect.New(targetType.Elem()).Elem()
+ if err := u.unmarshalValue(v, raw, valprop); err != nil {
+ return err
+ }
+ target.SetMapIndex(k, v)
+ }
+ return nil
+ }
+
+ // 64-bit integers can be encoded as strings. In this case we drop
+ // the quotes and proceed as normal.
+ isNum := targetType.Kind() == reflect.Int64 || targetType.Kind() == reflect.Uint64
+ if isNum && strings.HasPrefix(string(inputValue), `"`) {
+ inputValue = inputValue[1 : len(inputValue)-1]
+ }
+
+ // Use the encoding/json for parsing other value types.
+ return json.Unmarshal(inputValue, target.Addr().Interface())
+}
+
+// jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute.
+func jsonProperties(f reflect.StructField, origName bool) *proto.Properties {
+ var prop proto.Properties
+ prop.Init(f.Type, f.Name, f.Tag.Get("protobuf"), &f)
+ if origName || prop.JSONName == "" {
+ prop.JSONName = prop.OrigName
+ }
+ return &prop
+}
+
+type fieldNames struct {
+ orig, camel string
+}
+
+func acceptedJSONFieldNames(prop *proto.Properties) fieldNames {
+ opts := fieldNames{orig: prop.OrigName, camel: prop.OrigName}
+ if prop.JSONName != "" {
+ opts.camel = prop.JSONName
+ }
+ return opts
+}
+
+// Writer wrapper inspired by https://blog.golang.org/errors-are-values
+type errWriter struct {
+ writer io.Writer
+ err error
+}
+
+func (w *errWriter) write(str string) {
+ if w.err != nil {
+ return
+ }
+ _, w.err = w.writer.Write([]byte(str))
+}
+
+// Map fields may have key types of non-float scalars, strings and enums.
+// The easiest way to sort them in some deterministic order is to use fmt.
+// If this turns out to be inefficient we can always consider other options,
+// such as doing a Schwartzian transform.
+//
+// Numeric keys are sorted in numeric order per
+// https://developers.google.com/protocol-buffers/docs/proto#maps.
+type mapKeys []reflect.Value
+
+func (s mapKeys) Len() int { return len(s) }
+func (s mapKeys) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+func (s mapKeys) Less(i, j int) bool {
+ if k := s[i].Kind(); k == s[j].Kind() {
+ switch k {
+ case reflect.Int32, reflect.Int64:
+ return s[i].Int() < s[j].Int()
+ case reflect.Uint32, reflect.Uint64:
+ return s[i].Uint() < s[j].Uint()
+ }
+ }
+ return fmt.Sprint(s[i].Interface()) < fmt.Sprint(s[j].Interface())
+}
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go
new file mode 100644
index 000000000..e237df55c
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go
@@ -0,0 +1,563 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2015 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package jsonpb
+
+import (
+ "bytes"
+ "encoding/json"
+ "io"
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/golang/protobuf/proto"
+
+ pb "github.com/golang/protobuf/jsonpb/jsonpb_test_proto"
+ proto3pb "github.com/golang/protobuf/proto/proto3_proto"
+ anypb "github.com/golang/protobuf/ptypes/any"
+ durpb "github.com/golang/protobuf/ptypes/duration"
+ stpb "github.com/golang/protobuf/ptypes/struct"
+ tspb "github.com/golang/protobuf/ptypes/timestamp"
+ wpb "github.com/golang/protobuf/ptypes/wrappers"
+)
+
+var (
+ marshaler = Marshaler{}
+
+ marshalerAllOptions = Marshaler{
+ Indent: " ",
+ }
+
+ simpleObject = &pb.Simple{
+ OInt32: proto.Int32(-32),
+ OInt64: proto.Int64(-6400000000),
+ OUint32: proto.Uint32(32),
+ OUint64: proto.Uint64(6400000000),
+ OSint32: proto.Int32(-13),
+ OSint64: proto.Int64(-2600000000),
+ OFloat: proto.Float32(3.14),
+ ODouble: proto.Float64(6.02214179e23),
+ OBool: proto.Bool(true),
+ OString: proto.String("hello \"there\""),
+ OBytes: []byte("beep boop"),
+ }
+
+ simpleObjectJSON = `{` +
+ `"oBool":true,` +
+ `"oInt32":-32,` +
+ `"oInt64":"-6400000000",` +
+ `"oUint32":32,` +
+ `"oUint64":"6400000000",` +
+ `"oSint32":-13,` +
+ `"oSint64":"-2600000000",` +
+ `"oFloat":3.14,` +
+ `"oDouble":6.02214179e+23,` +
+ `"oString":"hello \"there\"",` +
+ `"oBytes":"YmVlcCBib29w"` +
+ `}`
+
+ simpleObjectPrettyJSON = `{
+ "oBool": true,
+ "oInt32": -32,
+ "oInt64": "-6400000000",
+ "oUint32": 32,
+ "oUint64": "6400000000",
+ "oSint32": -13,
+ "oSint64": "-2600000000",
+ "oFloat": 3.14,
+ "oDouble": 6.02214179e+23,
+ "oString": "hello \"there\"",
+ "oBytes": "YmVlcCBib29w"
+}`
+
+ repeatsObject = &pb.Repeats{
+ RBool: []bool{true, false, true},
+ RInt32: []int32{-3, -4, -5},
+ RInt64: []int64{-123456789, -987654321},
+ RUint32: []uint32{1, 2, 3},
+ RUint64: []uint64{6789012345, 3456789012},
+ RSint32: []int32{-1, -2, -3},
+ RSint64: []int64{-6789012345, -3456789012},
+ RFloat: []float32{3.14, 6.28},
+ RDouble: []float64{299792458 * 1e20, 6.62606957e-34},
+ RString: []string{"happy", "days"},
+ RBytes: [][]byte{[]byte("skittles"), []byte("m&m's")},
+ }
+
+ repeatsObjectJSON = `{` +
+ `"rBool":[true,false,true],` +
+ `"rInt32":[-3,-4,-5],` +
+ `"rInt64":["-123456789","-987654321"],` +
+ `"rUint32":[1,2,3],` +
+ `"rUint64":["6789012345","3456789012"],` +
+ `"rSint32":[-1,-2,-3],` +
+ `"rSint64":["-6789012345","-3456789012"],` +
+ `"rFloat":[3.14,6.28],` +
+ `"rDouble":[2.99792458e+28,6.62606957e-34],` +
+ `"rString":["happy","days"],` +
+ `"rBytes":["c2tpdHRsZXM=","bSZtJ3M="]` +
+ `}`
+
+ repeatsObjectPrettyJSON = `{
+ "rBool": [
+ true,
+ false,
+ true
+ ],
+ "rInt32": [
+ -3,
+ -4,
+ -5
+ ],
+ "rInt64": [
+ "-123456789",
+ "-987654321"
+ ],
+ "rUint32": [
+ 1,
+ 2,
+ 3
+ ],
+ "rUint64": [
+ "6789012345",
+ "3456789012"
+ ],
+ "rSint32": [
+ -1,
+ -2,
+ -3
+ ],
+ "rSint64": [
+ "-6789012345",
+ "-3456789012"
+ ],
+ "rFloat": [
+ 3.14,
+ 6.28
+ ],
+ "rDouble": [
+ 2.99792458e+28,
+ 6.62606957e-34
+ ],
+ "rString": [
+ "happy",
+ "days"
+ ],
+ "rBytes": [
+ "c2tpdHRsZXM=",
+ "bSZtJ3M="
+ ]
+}`
+
+ innerSimple = &pb.Simple{OInt32: proto.Int32(-32)}
+ innerSimple2 = &pb.Simple{OInt64: proto.Int64(25)}
+ innerRepeats = &pb.Repeats{RString: []string{"roses", "red"}}
+ innerRepeats2 = &pb.Repeats{RString: []string{"violets", "blue"}}
+ complexObject = &pb.Widget{
+ Color: pb.Widget_GREEN.Enum(),
+ RColor: []pb.Widget_Color{pb.Widget_RED, pb.Widget_GREEN, pb.Widget_BLUE},
+ Simple: innerSimple,
+ RSimple: []*pb.Simple{innerSimple, innerSimple2},
+ Repeats: innerRepeats,
+ RRepeats: []*pb.Repeats{innerRepeats, innerRepeats2},
+ }
+
+ complexObjectJSON = `{"color":"GREEN",` +
+ `"rColor":["RED","GREEN","BLUE"],` +
+ `"simple":{"oInt32":-32},` +
+ `"rSimple":[{"oInt32":-32},{"oInt64":"25"}],` +
+ `"repeats":{"rString":["roses","red"]},` +
+ `"rRepeats":[{"rString":["roses","red"]},{"rString":["violets","blue"]}]` +
+ `}`
+
+ complexObjectPrettyJSON = `{
+ "color": "GREEN",
+ "rColor": [
+ "RED",
+ "GREEN",
+ "BLUE"
+ ],
+ "simple": {
+ "oInt32": -32
+ },
+ "rSimple": [
+ {
+ "oInt32": -32
+ },
+ {
+ "oInt64": "25"
+ }
+ ],
+ "repeats": {
+ "rString": [
+ "roses",
+ "red"
+ ]
+ },
+ "rRepeats": [
+ {
+ "rString": [
+ "roses",
+ "red"
+ ]
+ },
+ {
+ "rString": [
+ "violets",
+ "blue"
+ ]
+ }
+ ]
+}`
+
+ colorPrettyJSON = `{
+ "color": 2
+}`
+
+ colorListPrettyJSON = `{
+ "color": 1000,
+ "rColor": [
+ "RED"
+ ]
+}`
+
+ nummyPrettyJSON = `{
+ "nummy": {
+ "1": 2,
+ "3": 4
+ }
+}`
+
+ objjyPrettyJSON = `{
+ "objjy": {
+ "1": {
+ "dub": 1
+ }
+ }
+}`
+ realNumber = &pb.Real{Value: proto.Float64(3.14159265359)}
+ realNumberName = "Pi"
+ complexNumber = &pb.Complex{Imaginary: proto.Float64(0.5772156649)}
+ realNumberJSON = `{` +
+ `"value":3.14159265359,` +
+ `"[jsonpb.Complex.real_extension]":{"imaginary":0.5772156649},` +
+ `"[jsonpb.name]":"Pi"` +
+ `}`
+
+ anySimple = &pb.KnownTypes{
+ An: &anypb.Any{
+ TypeUrl: "something.example.com/jsonpb.Simple",
+ Value: []byte{
+ // &pb.Simple{OBool:true}
+ 1 << 3, 1,
+ },
+ },
+ }
+ anySimpleJSON = `{"an":{"@type":"something.example.com/jsonpb.Simple","oBool":true}}`
+ anySimplePrettyJSON = `{
+ "an": {
+ "@type": "something.example.com/jsonpb.Simple",
+ "oBool": true
+ }
+}`
+
+ anyWellKnown = &pb.KnownTypes{
+ An: &anypb.Any{
+ TypeUrl: "type.googleapis.com/google.protobuf.Duration",
+ Value: []byte{
+ // &durpb.Duration{Seconds: 1, Nanos: 212000000 }
+ 1 << 3, 1, // seconds
+ 2 << 3, 0x80, 0xba, 0x8b, 0x65, // nanos
+ },
+ },
+ }
+ anyWellKnownJSON = `{"an":{"@type":"type.googleapis.com/google.protobuf.Duration","value":"1.212s"}}`
+ anyWellKnownPrettyJSON = `{
+ "an": {
+ "@type": "type.googleapis.com/google.protobuf.Duration",
+ "value": "1.212s"
+ }
+}`
+)
+
+func init() {
+ if err := proto.SetExtension(realNumber, pb.E_Name, &realNumberName); err != nil {
+ panic(err)
+ }
+ if err := proto.SetExtension(realNumber, pb.E_Complex_RealExtension, complexNumber); err != nil {
+ panic(err)
+ }
+}
+
+var marshalingTests = []struct {
+ desc string
+ marshaler Marshaler
+ pb proto.Message
+ json string
+}{
+ {"simple flat object", marshaler, simpleObject, simpleObjectJSON},
+ {"simple pretty object", marshalerAllOptions, simpleObject, simpleObjectPrettyJSON},
+ {"repeated fields flat object", marshaler, repeatsObject, repeatsObjectJSON},
+ {"repeated fields pretty object", marshalerAllOptions, repeatsObject, repeatsObjectPrettyJSON},
+ {"nested message/enum flat object", marshaler, complexObject, complexObjectJSON},
+ {"nested message/enum pretty object", marshalerAllOptions, complexObject, complexObjectPrettyJSON},
+ {"enum-string flat object", Marshaler{},
+ &pb.Widget{Color: pb.Widget_BLUE.Enum()}, `{"color":"BLUE"}`},
+ {"enum-value pretty object", Marshaler{EnumsAsInts: true, Indent: " "},
+ &pb.Widget{Color: pb.Widget_BLUE.Enum()}, colorPrettyJSON},
+ {"unknown enum value object", marshalerAllOptions,
+ &pb.Widget{Color: pb.Widget_Color(1000).Enum(), RColor: []pb.Widget_Color{pb.Widget_RED}}, colorListPrettyJSON},
+ {"repeated proto3 enum", Marshaler{},
+ &proto3pb.Message{RFunny: []proto3pb.Message_Humour{
+ proto3pb.Message_PUNS,
+ proto3pb.Message_SLAPSTICK,
+ }},
+ `{"rFunny":["PUNS","SLAPSTICK"]}`},
+ {"repeated proto3 enum as int", Marshaler{EnumsAsInts: true},
+ &proto3pb.Message{RFunny: []proto3pb.Message_Humour{
+ proto3pb.Message_PUNS,
+ proto3pb.Message_SLAPSTICK,
+ }},
+ `{"rFunny":[1,2]}`},
+ {"empty value", marshaler, &pb.Simple3{}, `{}`},
+ {"empty value emitted", Marshaler{EmitDefaults: true}, &pb.Simple3{}, `{"dub":0}`},
+ {"map<int64, int32>", marshaler, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}, `{"nummy":{"1":2,"3":4}}`},
+ {"map<int64, int32>", marshalerAllOptions, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}, nummyPrettyJSON},
+ {"map<string, string>", marshaler,
+ &pb.Mappy{Strry: map[string]string{`"one"`: "two", "three": "four"}},
+ `{"strry":{"\"one\"":"two","three":"four"}}`},
+ {"map<int32, Object>", marshaler,
+ &pb.Mappy{Objjy: map[int32]*pb.Simple3{1: &pb.Simple3{Dub: 1}}}, `{"objjy":{"1":{"dub":1}}}`},
+ {"map<int32, Object>", marshalerAllOptions,
+ &pb.Mappy{Objjy: map[int32]*pb.Simple3{1: &pb.Simple3{Dub: 1}}}, objjyPrettyJSON},
+ {"map<int64, string>", marshaler, &pb.Mappy{Buggy: map[int64]string{1234: "yup"}},
+ `{"buggy":{"1234":"yup"}}`},
+ {"map<bool, bool>", marshaler, &pb.Mappy{Booly: map[bool]bool{false: true}}, `{"booly":{"false":true}}`},
+ // TODO: This is broken.
+ //{"map<string, enum>", marshaler, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":"ROMAN"}`},
+ {"map<string, enum as int>", Marshaler{EnumsAsInts: true}, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":2}}`},
+ {"map<int32, bool>", marshaler, &pb.Mappy{S32Booly: map[int32]bool{1: true, 3: false, 10: true, 12: false}}, `{"s32booly":{"1":true,"3":false,"10":true,"12":false}}`},
+ {"map<int64, bool>", marshaler, &pb.Mappy{S64Booly: map[int64]bool{1: true, 3: false, 10: true, 12: false}}, `{"s64booly":{"1":true,"3":false,"10":true,"12":false}}`},
+ {"map<uint32, bool>", marshaler, &pb.Mappy{U32Booly: map[uint32]bool{1: true, 3: false, 10: true, 12: false}}, `{"u32booly":{"1":true,"3":false,"10":true,"12":false}}`},
+ {"map<uint64, bool>", marshaler, &pb.Mappy{U64Booly: map[uint64]bool{1: true, 3: false, 10: true, 12: false}}, `{"u64booly":{"1":true,"3":false,"10":true,"12":false}}`},
+ {"proto2 map<int64, string>", marshaler, &pb.Maps{MInt64Str: map[int64]string{213: "cat"}},
+ `{"mInt64Str":{"213":"cat"}}`},
+ {"proto2 map<bool, Object>", marshaler,
+ &pb.Maps{MBoolSimple: map[bool]*pb.Simple{true: &pb.Simple{OInt32: proto.Int32(1)}}},
+ `{"mBoolSimple":{"true":{"oInt32":1}}}`},
+ {"oneof, not set", marshaler, &pb.MsgWithOneof{}, `{}`},
+ {"oneof, set", marshaler, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Title{"Grand Poobah"}}, `{"title":"Grand Poobah"}`},
+ {"force orig_name", Marshaler{OrigName: true}, &pb.Simple{OInt32: proto.Int32(4)},
+ `{"o_int32":4}`},
+ {"proto2 extension", marshaler, realNumber, realNumberJSON},
+ {"Any with message", marshaler, anySimple, anySimpleJSON},
+ {"Any with message and indent", marshalerAllOptions, anySimple, anySimplePrettyJSON},
+ {"Any with WKT", marshaler, anyWellKnown, anyWellKnownJSON},
+ {"Any with WKT and indent", marshalerAllOptions, anyWellKnown, anyWellKnownPrettyJSON},
+ {"Duration", marshaler, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}, `{"dur":"3.000s"}`},
+ {"Struct", marshaler, &pb.KnownTypes{St: &stpb.Struct{
+ Fields: map[string]*stpb.Value{
+ "one": &stpb.Value{Kind: &stpb.Value_StringValue{"loneliest number"}},
+ "two": &stpb.Value{Kind: &stpb.Value_NullValue{stpb.NullValue_NULL_VALUE}},
+ },
+ }}, `{"st":{"one":"loneliest number","two":null}}`},
+ {"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) {
+ for _, tt := range marshalingTests {
+ json, err := tt.marshaler.MarshalToString(tt.pb)
+ if err != nil {
+ t.Errorf("%s: marshaling error: %v", tt.desc, err)
+ } else if tt.json != json {
+ t.Errorf("%s: got [%v] want [%v]", tt.desc, json, tt.json)
+ }
+ }
+}
+
+var unmarshalingTests = []struct {
+ desc string
+ unmarshaler Unmarshaler
+ json string
+ pb proto.Message
+}{
+ {"simple flat object", Unmarshaler{}, simpleObjectJSON, simpleObject},
+ {"simple pretty object", Unmarshaler{}, simpleObjectPrettyJSON, simpleObject},
+ {"repeated fields flat object", Unmarshaler{}, repeatsObjectJSON, repeatsObject},
+ {"repeated fields pretty object", Unmarshaler{}, repeatsObjectPrettyJSON, repeatsObject},
+ {"nested message/enum flat object", Unmarshaler{}, complexObjectJSON, complexObject},
+ {"nested message/enum pretty object", Unmarshaler{}, complexObjectPrettyJSON, complexObject},
+ {"enum-string object", Unmarshaler{}, `{"color":"BLUE"}`, &pb.Widget{Color: pb.Widget_BLUE.Enum()}},
+ {"enum-value object", Unmarshaler{}, "{\n \"color\": 2\n}", &pb.Widget{Color: pb.Widget_BLUE.Enum()}},
+ {"unknown field with allowed option", Unmarshaler{AllowUnknownFields: true}, `{"unknown": "foo"}`, new(pb.Simple)},
+ {"proto3 enum string", Unmarshaler{}, `{"hilarity":"PUNS"}`, &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}},
+ {"proto3 enum value", Unmarshaler{}, `{"hilarity":1}`, &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}},
+ {"unknown enum value object",
+ Unmarshaler{},
+ "{\n \"color\": 1000,\n \"r_color\": [\n \"RED\"\n ]\n}",
+ &pb.Widget{Color: pb.Widget_Color(1000).Enum(), RColor: []pb.Widget_Color{pb.Widget_RED}}},
+ {"repeated proto3 enum", Unmarshaler{}, `{"rFunny":["PUNS","SLAPSTICK"]}`,
+ &proto3pb.Message{RFunny: []proto3pb.Message_Humour{
+ proto3pb.Message_PUNS,
+ proto3pb.Message_SLAPSTICK,
+ }}},
+ {"repeated proto3 enum as int", Unmarshaler{}, `{"rFunny":[1,2]}`,
+ &proto3pb.Message{RFunny: []proto3pb.Message_Humour{
+ proto3pb.Message_PUNS,
+ proto3pb.Message_SLAPSTICK,
+ }}},
+ {"repeated proto3 enum as mix of strings and ints", Unmarshaler{}, `{"rFunny":["PUNS",2]}`,
+ &proto3pb.Message{RFunny: []proto3pb.Message_Humour{
+ proto3pb.Message_PUNS,
+ proto3pb.Message_SLAPSTICK,
+ }}},
+ {"unquoted int64 object", Unmarshaler{}, `{"oInt64":-314}`, &pb.Simple{OInt64: proto.Int64(-314)}},
+ {"unquoted uint64 object", Unmarshaler{}, `{"oUint64":123}`, &pb.Simple{OUint64: proto.Uint64(123)}},
+ {"map<int64, int32>", Unmarshaler{}, `{"nummy":{"1":2,"3":4}}`, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}},
+ {"map<string, string>", Unmarshaler{}, `{"strry":{"\"one\"":"two","three":"four"}}`, &pb.Mappy{Strry: map[string]string{`"one"`: "two", "three": "four"}}},
+ {"map<int32, Object>", Unmarshaler{}, `{"objjy":{"1":{"dub":1}}}`, &pb.Mappy{Objjy: map[int32]*pb.Simple3{1: &pb.Simple3{Dub: 1}}}},
+ // TODO: This is broken.
+ //{"map<string, enum>", Unmarshaler{}, `{"enumy":{"XIV":"ROMAN"}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}},
+ {"map<string, enum as int>", Unmarshaler{}, `{"enumy":{"XIV":2}}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}},
+ {"oneof", Unmarshaler{}, `{"salary":31000}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Salary{31000}}},
+ {"oneof spec name", Unmarshaler{}, `{"Country":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Country{"Australia"}}},
+ {"oneof orig_name", Unmarshaler{}, `{"Country":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Country{"Australia"}}},
+ {"oneof spec name2", Unmarshaler{}, `{"homeAddress":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_HomeAddress{"Australia"}}},
+ {"oneof orig_name2", Unmarshaler{}, `{"home_address":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_HomeAddress{"Australia"}}},
+ {"orig_name input", Unmarshaler{}, `{"o_bool":true}`, &pb.Simple{OBool: proto.Bool(true)}},
+ {"camelName input", Unmarshaler{}, `{"oBool":true}`, &pb.Simple{OBool: proto.Bool(true)}},
+
+ {"Duration", Unmarshaler{}, `{"dur":"3.000s"}`, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}},
+ {"null Duration", Unmarshaler{}, `{"dur":null}`, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 0}}},
+ {"Timestamp", Unmarshaler{}, `{"ts":"2014-05-13T16:53:20.021Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}},
+ {"PreEpochTimestamp", Unmarshaler{}, `{"ts":"1969-12-31T23:59:58.999999995Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: -2, Nanos: 999999995}}},
+ {"ZeroTimeTimestamp", Unmarshaler{}, `{"ts":"0001-01-01T00:00:00Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: -62135596800, Nanos: 0}}},
+ {"null Timestamp", Unmarshaler{}, `{"ts":null}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 0, Nanos: 0}}},
+
+ {"DoubleValue", Unmarshaler{}, `{"dbl":1.2}`, &pb.KnownTypes{Dbl: &wpb.DoubleValue{Value: 1.2}}},
+ {"FloatValue", Unmarshaler{}, `{"flt":1.2}`, &pb.KnownTypes{Flt: &wpb.FloatValue{Value: 1.2}}},
+ {"Int64Value", Unmarshaler{}, `{"i64":"-3"}`, &pb.KnownTypes{I64: &wpb.Int64Value{Value: -3}}},
+ {"UInt64Value", Unmarshaler{}, `{"u64":"3"}`, &pb.KnownTypes{U64: &wpb.UInt64Value{Value: 3}}},
+ {"Int32Value", Unmarshaler{}, `{"i32":-4}`, &pb.KnownTypes{I32: &wpb.Int32Value{Value: -4}}},
+ {"UInt32Value", Unmarshaler{}, `{"u32":4}`, &pb.KnownTypes{U32: &wpb.UInt32Value{Value: 4}}},
+ {"BoolValue", Unmarshaler{}, `{"bool":true}`, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}},
+ {"StringValue", Unmarshaler{}, `{"str":"plush"}`, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}},
+ {"BytesValue", Unmarshaler{}, `{"bytes":"d293"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}},
+ // `null` is also a permissible value. Let's just test one.
+ {"null DoubleValue", Unmarshaler{}, `{"dbl":null}`, &pb.KnownTypes{Dbl: &wpb.DoubleValue{}}},
+}
+
+func TestUnmarshaling(t *testing.T) {
+ for _, tt := range unmarshalingTests {
+ // Make a new instance of the type of our expected object.
+ p := reflect.New(reflect.TypeOf(tt.pb).Elem()).Interface().(proto.Message)
+
+ err := tt.unmarshaler.Unmarshal(strings.NewReader(tt.json), p)
+ if err != nil {
+ t.Errorf("%s: %v", tt.desc, err)
+ continue
+ }
+
+ // For easier diffs, compare text strings of the protos.
+ exp := proto.MarshalTextString(tt.pb)
+ act := proto.MarshalTextString(p)
+ if string(exp) != string(act) {
+ t.Errorf("%s: got [%s] want [%s]", tt.desc, act, exp)
+ }
+ }
+}
+
+func TestUnmarshalNext(t *testing.T) {
+ // We only need to check against a few, not all of them.
+ tests := unmarshalingTests[:5]
+
+ // Create a buffer with many concatenated JSON objects.
+ var b bytes.Buffer
+ for _, tt := range tests {
+ b.WriteString(tt.json)
+ }
+
+ dec := json.NewDecoder(&b)
+ for _, tt := range tests {
+ // Make a new instance of the type of our expected object.
+ p := reflect.New(reflect.TypeOf(tt.pb).Elem()).Interface().(proto.Message)
+
+ err := tt.unmarshaler.UnmarshalNext(dec, p)
+ if err != nil {
+ t.Errorf("%s: %v", tt.desc, err)
+ continue
+ }
+
+ // For easier diffs, compare text strings of the protos.
+ exp := proto.MarshalTextString(tt.pb)
+ act := proto.MarshalTextString(p)
+ if string(exp) != string(act) {
+ t.Errorf("%s: got [%s] want [%s]", tt.desc, act, exp)
+ }
+ }
+
+ p := &pb.Simple{}
+ err := new(Unmarshaler).UnmarshalNext(dec, p)
+ if err != io.EOF {
+ t.Errorf("eof: got %v, expected io.EOF", err)
+ }
+}
+
+var unmarshalingShouldError = []struct {
+ desc string
+ in string
+ pb proto.Message
+}{
+ {"a value", "666", new(pb.Simple)},
+ {"gibberish", "{adskja123;l23=-=", new(pb.Simple)},
+ {"unknown field", `{"unknown": "foo"}`, new(pb.Simple)},
+ {"unknown enum name", `{"hilarity":"DAVE"}`, new(proto3pb.Message)},
+}
+
+func TestUnmarshalingBadInput(t *testing.T) {
+ for _, tt := range unmarshalingShouldError {
+ err := UnmarshalString(tt.in, tt.pb)
+ if err == nil {
+ t.Errorf("an error was expected when parsing %q instead of an object", tt.desc)
+ }
+ }
+}
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile
new file mode 100644
index 000000000..eeda8ae53
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile
@@ -0,0 +1,33 @@
+# Go support for Protocol Buffers - Google's data interchange format
+#
+# Copyright 2015 The Go Authors. All rights reserved.
+# https://github.com/golang/protobuf
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+regenerate:
+ protoc --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers:. *.proto
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go
new file mode 100644
index 000000000..d6ff6413f
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go
@@ -0,0 +1,207 @@
+// Code generated by protoc-gen-go.
+// source: more_test_objects.proto
+// DO NOT EDIT!
+
+/*
+Package jsonpb is a generated protocol buffer package.
+
+It is generated from these files:
+ more_test_objects.proto
+ test_objects.proto
+
+It has these top-level messages:
+ Simple3
+ Mappy
+ Simple
+ Repeats
+ Widget
+ Maps
+ MsgWithOneof
+ Real
+ Complex
+ KnownTypes
+*/
+package jsonpb
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Numeral int32
+
+const (
+ Numeral_UNKNOWN Numeral = 0
+ Numeral_ARABIC Numeral = 1
+ Numeral_ROMAN Numeral = 2
+)
+
+var Numeral_name = map[int32]string{
+ 0: "UNKNOWN",
+ 1: "ARABIC",
+ 2: "ROMAN",
+}
+var Numeral_value = map[string]int32{
+ "UNKNOWN": 0,
+ "ARABIC": 1,
+ "ROMAN": 2,
+}
+
+func (x Numeral) String() string {
+ return proto.EnumName(Numeral_name, int32(x))
+}
+func (Numeral) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
+
+type Simple3 struct {
+ Dub float64 `protobuf:"fixed64,1,opt,name=dub" json:"dub,omitempty"`
+}
+
+func (m *Simple3) Reset() { *m = Simple3{} }
+func (m *Simple3) String() string { return proto.CompactTextString(m) }
+func (*Simple3) ProtoMessage() {}
+func (*Simple3) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
+
+func (m *Simple3) GetDub() float64 {
+ if m != nil {
+ return m.Dub
+ }
+ return 0
+}
+
+type Mappy struct {
+ Nummy map[int64]int32 `protobuf:"bytes,1,rep,name=nummy" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
+ Strry map[string]string `protobuf:"bytes,2,rep,name=strry" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ Objjy map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ Buggy map[int64]string `protobuf:"bytes,4,rep,name=buggy" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ Booly map[bool]bool `protobuf:"bytes,5,rep,name=booly" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
+ Enumy map[string]Numeral `protobuf:"bytes,6,rep,name=enumy" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=jsonpb.Numeral"`
+ S32Booly map[int32]bool `protobuf:"bytes,7,rep,name=s32booly" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
+ S64Booly map[int64]bool `protobuf:"bytes,8,rep,name=s64booly" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
+ U32Booly map[uint32]bool `protobuf:"bytes,9,rep,name=u32booly" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
+ U64Booly map[uint64]bool `protobuf:"bytes,10,rep,name=u64booly" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
+}
+
+func (m *Mappy) Reset() { *m = Mappy{} }
+func (m *Mappy) String() string { return proto.CompactTextString(m) }
+func (*Mappy) ProtoMessage() {}
+func (*Mappy) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
+
+func (m *Mappy) GetNummy() map[int64]int32 {
+ if m != nil {
+ return m.Nummy
+ }
+ return nil
+}
+
+func (m *Mappy) GetStrry() map[string]string {
+ if m != nil {
+ return m.Strry
+ }
+ return nil
+}
+
+func (m *Mappy) GetObjjy() map[int32]*Simple3 {
+ if m != nil {
+ return m.Objjy
+ }
+ return nil
+}
+
+func (m *Mappy) GetBuggy() map[int64]string {
+ if m != nil {
+ return m.Buggy
+ }
+ return nil
+}
+
+func (m *Mappy) GetBooly() map[bool]bool {
+ if m != nil {
+ return m.Booly
+ }
+ return nil
+}
+
+func (m *Mappy) GetEnumy() map[string]Numeral {
+ if m != nil {
+ return m.Enumy
+ }
+ return nil
+}
+
+func (m *Mappy) GetS32Booly() map[int32]bool {
+ if m != nil {
+ return m.S32Booly
+ }
+ return nil
+}
+
+func (m *Mappy) GetS64Booly() map[int64]bool {
+ if m != nil {
+ return m.S64Booly
+ }
+ return nil
+}
+
+func (m *Mappy) GetU32Booly() map[uint32]bool {
+ if m != nil {
+ return m.U32Booly
+ }
+ return nil
+}
+
+func (m *Mappy) GetU64Booly() map[uint64]bool {
+ if m != nil {
+ return m.U64Booly
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*Simple3)(nil), "jsonpb.Simple3")
+ proto.RegisterType((*Mappy)(nil), "jsonpb.Mappy")
+ proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value)
+}
+
+func init() { proto.RegisterFile("more_test_objects.proto", fileDescriptor0) }
+
+var fileDescriptor0 = []byte{
+ // 444 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x94, 0xc1, 0x6b, 0xdb, 0x30,
+ 0x14, 0x87, 0xe7, 0xa4, 0x4e, 0xec, 0x17, 0xba, 0x19, 0x31, 0x98, 0x58, 0x2f, 0xa1, 0x30, 0x08,
+ 0x83, 0xf9, 0x90, 0x8c, 0xad, 0x6c, 0xa7, 0x74, 0xf4, 0x50, 0x46, 0x1d, 0x70, 0x09, 0x3b, 0x96,
+ 0x78, 0x13, 0x65, 0x9e, 0x6d, 0x19, 0xdb, 0x1a, 0xe8, 0x8f, 0x1f, 0x8c, 0x27, 0xcb, 0xb5, 0x6c,
+ 0x14, 0xd2, 0x9b, 0xcc, 0xef, 0xfb, 0xf2, 0x9e, 0xf4, 0x1e, 0x81, 0x37, 0x39, 0xaf, 0xd8, 0x43,
+ 0xc3, 0xea, 0xe6, 0x81, 0x27, 0x29, 0xfb, 0xd9, 0xd4, 0x61, 0x59, 0xf1, 0x86, 0x93, 0x59, 0x5a,
+ 0xf3, 0xa2, 0x4c, 0x2e, 0x2f, 0x60, 0x7e, 0xff, 0x3b, 0x2f, 0x33, 0xb6, 0x21, 0x01, 0x4c, 0x7f,
+ 0x89, 0x84, 0x3a, 0x4b, 0x67, 0xe5, 0xc4, 0x78, 0xbc, 0xfc, 0xe7, 0x81, 0x7b, 0x77, 0x28, 0x4b,
+ 0x49, 0x42, 0x70, 0x0b, 0x91, 0xe7, 0x92, 0x3a, 0xcb, 0xe9, 0x6a, 0x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3, 0x9d, 0x69, 0x2e,
+ 0xd6, 0xaf, 0xba, 0x9b, 0xe8, 0x9d, 0x1e, 0x35, 0xd1, 0xef, 0xc5, 0xa9, 0xf6, 0xfd, 0xb1, 0xf9,
+ 0xf4, 0x20, 0xa6, 0xe9, 0x59, 0x4c, 0x6f, 0xd4, 0x7e, 0xbf, 0x2b, 0x96, 0x8b, 0x0f, 0xda, 0x7f,
+ 0xd9, 0xb7, 0x1f, 0x89, 0x9c, 0x55, 0x87, 0xcc, 0xfc, 0xa9, 0xaf, 0x70, 0x3e, 0xd8, 0x21, 0xcb,
+ 0x63, 0x1c, 0xef, 0x03, 0x65, 0x73, 0xaa, 0xa7, 0xae, 0x3f, 0x96, 0xf7, 0xc7, 0x2a, 0x9f, 0x3f,
+ 0x47, 0x3e, 0x56, 0xf9, 0xec, 0x84, 0xfc, 0xfe, 0x03, 0xcc, 0xf5, 0x4b, 0x90, 0x05, 0xcc, 0xf7,
+ 0xd1, 0xf7, 0x68, 0xf7, 0x23, 0x0a, 0x5e, 0x10, 0x80, 0xd9, 0x36, 0xde, 0x5e, 0xdf, 0x7e, 0x0b,
+ 0x1c, 0xe2, 0x83, 0x1b, 0xef, 0xee, 0xb6, 0x51, 0x30, 0x49, 0x66, 0xea, 0xaf, 0x6d, 0xf3, 0x3f,
+ 0x00, 0x00, 0xff, 0xff, 0xa2, 0x4b, 0xe1, 0x77, 0xf5, 0x04, 0x00, 0x00,
+}
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto
new file mode 100644
index 000000000..43b440e2d
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto
@@ -0,0 +1,57 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2015 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package jsonpb;
+
+message Simple3 {
+ double dub = 1;
+}
+
+enum Numeral {
+ UNKNOWN = 0;
+ ARABIC = 1;
+ ROMAN = 2;
+}
+
+message Mappy {
+ map<int64, int32> nummy = 1;
+ map<string, string> strry = 2;
+ map<int32, Simple3> objjy = 3;
+ map<int64, string> buggy = 4;
+ map<bool, bool> booly = 5;
+ map<string, Numeral> enumy = 6;
+ map<int32, bool> s32booly = 7;
+ map<int64, bool> s64booly = 8;
+ map<uint32, bool> u32booly = 9;
+ map<uint64, bool> u64booly = 10;
+}
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go
new file mode 100644
index 000000000..a5dfcd269
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go
@@ -0,0 +1,771 @@
+// Code generated by protoc-gen-go.
+// source: test_objects.proto
+// DO NOT EDIT!
+
+package jsonpb
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+import google_protobuf "github.com/golang/protobuf/ptypes/any"
+import google_protobuf1 "github.com/golang/protobuf/ptypes/duration"
+import google_protobuf2 "github.com/golang/protobuf/ptypes/struct"
+import google_protobuf3 "github.com/golang/protobuf/ptypes/timestamp"
+import google_protobuf4 "github.com/golang/protobuf/ptypes/wrappers"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+type Widget_Color int32
+
+const (
+ Widget_RED Widget_Color = 0
+ Widget_GREEN Widget_Color = 1
+ Widget_BLUE Widget_Color = 2
+)
+
+var Widget_Color_name = map[int32]string{
+ 0: "RED",
+ 1: "GREEN",
+ 2: "BLUE",
+}
+var Widget_Color_value = map[string]int32{
+ "RED": 0,
+ "GREEN": 1,
+ "BLUE": 2,
+}
+
+func (x Widget_Color) Enum() *Widget_Color {
+ p := new(Widget_Color)
+ *p = x
+ return p
+}
+func (x Widget_Color) String() string {
+ return proto.EnumName(Widget_Color_name, int32(x))
+}
+func (x *Widget_Color) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(Widget_Color_value, data, "Widget_Color")
+ if err != nil {
+ return err
+ }
+ *x = Widget_Color(value)
+ return nil
+}
+func (Widget_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{2, 0} }
+
+// Test message for holding primitive types.
+type Simple struct {
+ OBool *bool `protobuf:"varint,1,opt,name=o_bool,json=oBool" json:"o_bool,omitempty"`
+ OInt32 *int32 `protobuf:"varint,2,opt,name=o_int32,json=oInt32" json:"o_int32,omitempty"`
+ OInt64 *int64 `protobuf:"varint,3,opt,name=o_int64,json=oInt64" json:"o_int64,omitempty"`
+ OUint32 *uint32 `protobuf:"varint,4,opt,name=o_uint32,json=oUint32" json:"o_uint32,omitempty"`
+ OUint64 *uint64 `protobuf:"varint,5,opt,name=o_uint64,json=oUint64" json:"o_uint64,omitempty"`
+ OSint32 *int32 `protobuf:"zigzag32,6,opt,name=o_sint32,json=oSint32" json:"o_sint32,omitempty"`
+ OSint64 *int64 `protobuf:"zigzag64,7,opt,name=o_sint64,json=oSint64" json:"o_sint64,omitempty"`
+ OFloat *float32 `protobuf:"fixed32,8,opt,name=o_float,json=oFloat" json:"o_float,omitempty"`
+ ODouble *float64 `protobuf:"fixed64,9,opt,name=o_double,json=oDouble" json:"o_double,omitempty"`
+ OString *string `protobuf:"bytes,10,opt,name=o_string,json=oString" json:"o_string,omitempty"`
+ OBytes []byte `protobuf:"bytes,11,opt,name=o_bytes,json=oBytes" json:"o_bytes,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Simple) Reset() { *m = Simple{} }
+func (m *Simple) String() string { return proto.CompactTextString(m) }
+func (*Simple) ProtoMessage() {}
+func (*Simple) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
+
+func (m *Simple) GetOBool() bool {
+ if m != nil && m.OBool != nil {
+ return *m.OBool
+ }
+ return false
+}
+
+func (m *Simple) GetOInt32() int32 {
+ if m != nil && m.OInt32 != nil {
+ return *m.OInt32
+ }
+ return 0
+}
+
+func (m *Simple) GetOInt64() int64 {
+ if m != nil && m.OInt64 != nil {
+ return *m.OInt64
+ }
+ return 0
+}
+
+func (m *Simple) GetOUint32() uint32 {
+ if m != nil && m.OUint32 != nil {
+ return *m.OUint32
+ }
+ return 0
+}
+
+func (m *Simple) GetOUint64() uint64 {
+ if m != nil && m.OUint64 != nil {
+ return *m.OUint64
+ }
+ return 0
+}
+
+func (m *Simple) GetOSint32() int32 {
+ if m != nil && m.OSint32 != nil {
+ return *m.OSint32
+ }
+ return 0
+}
+
+func (m *Simple) GetOSint64() int64 {
+ if m != nil && m.OSint64 != nil {
+ return *m.OSint64
+ }
+ return 0
+}
+
+func (m *Simple) GetOFloat() float32 {
+ if m != nil && m.OFloat != nil {
+ return *m.OFloat
+ }
+ return 0
+}
+
+func (m *Simple) GetODouble() float64 {
+ if m != nil && m.ODouble != nil {
+ return *m.ODouble
+ }
+ return 0
+}
+
+func (m *Simple) GetOString() string {
+ if m != nil && m.OString != nil {
+ return *m.OString
+ }
+ return ""
+}
+
+func (m *Simple) GetOBytes() []byte {
+ if m != nil {
+ return m.OBytes
+ }
+ return nil
+}
+
+// Test message for holding repeated primitives.
+type Repeats struct {
+ RBool []bool `protobuf:"varint,1,rep,name=r_bool,json=rBool" json:"r_bool,omitempty"`
+ RInt32 []int32 `protobuf:"varint,2,rep,name=r_int32,json=rInt32" json:"r_int32,omitempty"`
+ RInt64 []int64 `protobuf:"varint,3,rep,name=r_int64,json=rInt64" json:"r_int64,omitempty"`
+ RUint32 []uint32 `protobuf:"varint,4,rep,name=r_uint32,json=rUint32" json:"r_uint32,omitempty"`
+ RUint64 []uint64 `protobuf:"varint,5,rep,name=r_uint64,json=rUint64" json:"r_uint64,omitempty"`
+ RSint32 []int32 `protobuf:"zigzag32,6,rep,name=r_sint32,json=rSint32" json:"r_sint32,omitempty"`
+ RSint64 []int64 `protobuf:"zigzag64,7,rep,name=r_sint64,json=rSint64" json:"r_sint64,omitempty"`
+ RFloat []float32 `protobuf:"fixed32,8,rep,name=r_float,json=rFloat" json:"r_float,omitempty"`
+ RDouble []float64 `protobuf:"fixed64,9,rep,name=r_double,json=rDouble" json:"r_double,omitempty"`
+ RString []string `protobuf:"bytes,10,rep,name=r_string,json=rString" json:"r_string,omitempty"`
+ RBytes [][]byte `protobuf:"bytes,11,rep,name=r_bytes,json=rBytes" json:"r_bytes,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Repeats) Reset() { *m = Repeats{} }
+func (m *Repeats) String() string { return proto.CompactTextString(m) }
+func (*Repeats) ProtoMessage() {}
+func (*Repeats) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} }
+
+func (m *Repeats) GetRBool() []bool {
+ if m != nil {
+ return m.RBool
+ }
+ return nil
+}
+
+func (m *Repeats) GetRInt32() []int32 {
+ if m != nil {
+ return m.RInt32
+ }
+ return nil
+}
+
+func (m *Repeats) GetRInt64() []int64 {
+ if m != nil {
+ return m.RInt64
+ }
+ return nil
+}
+
+func (m *Repeats) GetRUint32() []uint32 {
+ if m != nil {
+ return m.RUint32
+ }
+ return nil
+}
+
+func (m *Repeats) GetRUint64() []uint64 {
+ if m != nil {
+ return m.RUint64
+ }
+ return nil
+}
+
+func (m *Repeats) GetRSint32() []int32 {
+ if m != nil {
+ return m.RSint32
+ }
+ return nil
+}
+
+func (m *Repeats) GetRSint64() []int64 {
+ if m != nil {
+ return m.RSint64
+ }
+ return nil
+}
+
+func (m *Repeats) GetRFloat() []float32 {
+ if m != nil {
+ return m.RFloat
+ }
+ return nil
+}
+
+func (m *Repeats) GetRDouble() []float64 {
+ if m != nil {
+ return m.RDouble
+ }
+ return nil
+}
+
+func (m *Repeats) GetRString() []string {
+ if m != nil {
+ return m.RString
+ }
+ return nil
+}
+
+func (m *Repeats) GetRBytes() [][]byte {
+ if m != nil {
+ return m.RBytes
+ }
+ return nil
+}
+
+// Test message for holding enums and nested messages.
+type Widget struct {
+ Color *Widget_Color `protobuf:"varint,1,opt,name=color,enum=jsonpb.Widget_Color" json:"color,omitempty"`
+ RColor []Widget_Color `protobuf:"varint,2,rep,name=r_color,json=rColor,enum=jsonpb.Widget_Color" json:"r_color,omitempty"`
+ Simple *Simple `protobuf:"bytes,10,opt,name=simple" json:"simple,omitempty"`
+ RSimple []*Simple `protobuf:"bytes,11,rep,name=r_simple,json=rSimple" json:"r_simple,omitempty"`
+ Repeats *Repeats `protobuf:"bytes,20,opt,name=repeats" json:"repeats,omitempty"`
+ RRepeats []*Repeats `protobuf:"bytes,21,rep,name=r_repeats,json=rRepeats" json:"r_repeats,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Widget) Reset() { *m = Widget{} }
+func (m *Widget) String() string { return proto.CompactTextString(m) }
+func (*Widget) ProtoMessage() {}
+func (*Widget) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
+
+func (m *Widget) GetColor() Widget_Color {
+ if m != nil && m.Color != nil {
+ return *m.Color
+ }
+ return Widget_RED
+}
+
+func (m *Widget) GetRColor() []Widget_Color {
+ if m != nil {
+ return m.RColor
+ }
+ return nil
+}
+
+func (m *Widget) GetSimple() *Simple {
+ if m != nil {
+ return m.Simple
+ }
+ return nil
+}
+
+func (m *Widget) GetRSimple() []*Simple {
+ if m != nil {
+ return m.RSimple
+ }
+ return nil
+}
+
+func (m *Widget) GetRepeats() *Repeats {
+ if m != nil {
+ return m.Repeats
+ }
+ return nil
+}
+
+func (m *Widget) GetRRepeats() []*Repeats {
+ if m != nil {
+ return m.RRepeats
+ }
+ return nil
+}
+
+type Maps struct {
+ MInt64Str map[int64]string `protobuf:"bytes,1,rep,name=m_int64_str,json=mInt64Str" json:"m_int64_str,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ MBoolSimple map[bool]*Simple `protobuf:"bytes,2,rep,name=m_bool_simple,json=mBoolSimple" json:"m_bool_simple,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Maps) Reset() { *m = Maps{} }
+func (m *Maps) String() string { return proto.CompactTextString(m) }
+func (*Maps) ProtoMessage() {}
+func (*Maps) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
+
+func (m *Maps) GetMInt64Str() map[int64]string {
+ if m != nil {
+ return m.MInt64Str
+ }
+ return nil
+}
+
+func (m *Maps) GetMBoolSimple() map[bool]*Simple {
+ if m != nil {
+ return m.MBoolSimple
+ }
+ return nil
+}
+
+type MsgWithOneof struct {
+ // Types that are valid to be assigned to Union:
+ // *MsgWithOneof_Title
+ // *MsgWithOneof_Salary
+ // *MsgWithOneof_Country
+ // *MsgWithOneof_HomeAddress
+ Union isMsgWithOneof_Union `protobuf_oneof:"union"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *MsgWithOneof) Reset() { *m = MsgWithOneof{} }
+func (m *MsgWithOneof) String() string { return proto.CompactTextString(m) }
+func (*MsgWithOneof) ProtoMessage() {}
+func (*MsgWithOneof) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} }
+
+type isMsgWithOneof_Union interface {
+ isMsgWithOneof_Union()
+}
+
+type MsgWithOneof_Title struct {
+ Title string `protobuf:"bytes,1,opt,name=title,oneof"`
+}
+type MsgWithOneof_Salary struct {
+ Salary int64 `protobuf:"varint,2,opt,name=salary,oneof"`
+}
+type MsgWithOneof_Country struct {
+ Country string `protobuf:"bytes,3,opt,name=Country,oneof"`
+}
+type MsgWithOneof_HomeAddress struct {
+ HomeAddress string `protobuf:"bytes,4,opt,name=home_address,json=homeAddress,oneof"`
+}
+
+func (*MsgWithOneof_Title) isMsgWithOneof_Union() {}
+func (*MsgWithOneof_Salary) isMsgWithOneof_Union() {}
+func (*MsgWithOneof_Country) isMsgWithOneof_Union() {}
+func (*MsgWithOneof_HomeAddress) isMsgWithOneof_Union() {}
+
+func (m *MsgWithOneof) GetUnion() isMsgWithOneof_Union {
+ if m != nil {
+ return m.Union
+ }
+ return nil
+}
+
+func (m *MsgWithOneof) GetTitle() string {
+ if x, ok := m.GetUnion().(*MsgWithOneof_Title); ok {
+ return x.Title
+ }
+ return ""
+}
+
+func (m *MsgWithOneof) GetSalary() int64 {
+ if x, ok := m.GetUnion().(*MsgWithOneof_Salary); ok {
+ return x.Salary
+ }
+ return 0
+}
+
+func (m *MsgWithOneof) GetCountry() string {
+ if x, ok := m.GetUnion().(*MsgWithOneof_Country); ok {
+ return x.Country
+ }
+ return ""
+}
+
+func (m *MsgWithOneof) GetHomeAddress() string {
+ if x, ok := m.GetUnion().(*MsgWithOneof_HomeAddress); ok {
+ return x.HomeAddress
+ }
+ return ""
+}
+
+// XXX_OneofFuncs is for the internal use of the proto package.
+func (*MsgWithOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
+ return _MsgWithOneof_OneofMarshaler, _MsgWithOneof_OneofUnmarshaler, _MsgWithOneof_OneofSizer, []interface{}{
+ (*MsgWithOneof_Title)(nil),
+ (*MsgWithOneof_Salary)(nil),
+ (*MsgWithOneof_Country)(nil),
+ (*MsgWithOneof_HomeAddress)(nil),
+ }
+}
+
+func _MsgWithOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
+ m := msg.(*MsgWithOneof)
+ // union
+ switch x := m.Union.(type) {
+ case *MsgWithOneof_Title:
+ b.EncodeVarint(1<<3 | proto.WireBytes)
+ b.EncodeStringBytes(x.Title)
+ case *MsgWithOneof_Salary:
+ b.EncodeVarint(2<<3 | proto.WireVarint)
+ b.EncodeVarint(uint64(x.Salary))
+ case *MsgWithOneof_Country:
+ b.EncodeVarint(3<<3 | proto.WireBytes)
+ b.EncodeStringBytes(x.Country)
+ case *MsgWithOneof_HomeAddress:
+ b.EncodeVarint(4<<3 | proto.WireBytes)
+ b.EncodeStringBytes(x.HomeAddress)
+ case nil:
+ default:
+ return fmt.Errorf("MsgWithOneof.Union has unexpected type %T", x)
+ }
+ return nil
+}
+
+func _MsgWithOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
+ m := msg.(*MsgWithOneof)
+ switch tag {
+ case 1: // union.title
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeStringBytes()
+ m.Union = &MsgWithOneof_Title{x}
+ return true, err
+ case 2: // union.salary
+ if wire != proto.WireVarint {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeVarint()
+ m.Union = &MsgWithOneof_Salary{int64(x)}
+ return true, err
+ case 3: // union.Country
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeStringBytes()
+ m.Union = &MsgWithOneof_Country{x}
+ return true, err
+ case 4: // union.home_address
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeStringBytes()
+ m.Union = &MsgWithOneof_HomeAddress{x}
+ return true, err
+ default:
+ return false, nil
+ }
+}
+
+func _MsgWithOneof_OneofSizer(msg proto.Message) (n int) {
+ m := msg.(*MsgWithOneof)
+ // union
+ switch x := m.Union.(type) {
+ case *MsgWithOneof_Title:
+ n += proto.SizeVarint(1<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(len(x.Title)))
+ n += len(x.Title)
+ case *MsgWithOneof_Salary:
+ n += proto.SizeVarint(2<<3 | proto.WireVarint)
+ n += proto.SizeVarint(uint64(x.Salary))
+ case *MsgWithOneof_Country:
+ n += proto.SizeVarint(3<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(len(x.Country)))
+ n += len(x.Country)
+ case *MsgWithOneof_HomeAddress:
+ n += proto.SizeVarint(4<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(len(x.HomeAddress)))
+ n += len(x.HomeAddress)
+ case nil:
+ default:
+ panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
+ }
+ return n
+}
+
+type Real struct {
+ Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"`
+ proto.XXX_InternalExtensions `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Real) Reset() { *m = Real{} }
+func (m *Real) String() string { return proto.CompactTextString(m) }
+func (*Real) ProtoMessage() {}
+func (*Real) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
+
+var extRange_Real = []proto.ExtensionRange{
+ {100, 536870911},
+}
+
+func (*Real) ExtensionRangeArray() []proto.ExtensionRange {
+ return extRange_Real
+}
+
+func (m *Real) GetValue() float64 {
+ if m != nil && m.Value != nil {
+ return *m.Value
+ }
+ return 0
+}
+
+type Complex struct {
+ Imaginary *float64 `protobuf:"fixed64,1,opt,name=imaginary" json:"imaginary,omitempty"`
+ proto.XXX_InternalExtensions `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Complex) Reset() { *m = Complex{} }
+func (m *Complex) String() string { return proto.CompactTextString(m) }
+func (*Complex) ProtoMessage() {}
+func (*Complex) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} }
+
+var extRange_Complex = []proto.ExtensionRange{
+ {100, 536870911},
+}
+
+func (*Complex) ExtensionRangeArray() []proto.ExtensionRange {
+ return extRange_Complex
+}
+
+func (m *Complex) GetImaginary() float64 {
+ if m != nil && m.Imaginary != nil {
+ return *m.Imaginary
+ }
+ return 0
+}
+
+var E_Complex_RealExtension = &proto.ExtensionDesc{
+ ExtendedType: (*Real)(nil),
+ ExtensionType: (*Complex)(nil),
+ Field: 123,
+ Name: "jsonpb.Complex.real_extension",
+ Tag: "bytes,123,opt,name=real_extension,json=realExtension",
+ Filename: "test_objects.proto",
+}
+
+type KnownTypes struct {
+ An *google_protobuf.Any `protobuf:"bytes,14,opt,name=an" json:"an,omitempty"`
+ Dur *google_protobuf1.Duration `protobuf:"bytes,1,opt,name=dur" json:"dur,omitempty"`
+ St *google_protobuf2.Struct `protobuf:"bytes,12,opt,name=st" json:"st,omitempty"`
+ Ts *google_protobuf3.Timestamp `protobuf:"bytes,2,opt,name=ts" json:"ts,omitempty"`
+ Dbl *google_protobuf4.DoubleValue `protobuf:"bytes,3,opt,name=dbl" json:"dbl,omitempty"`
+ Flt *google_protobuf4.FloatValue `protobuf:"bytes,4,opt,name=flt" json:"flt,omitempty"`
+ I64 *google_protobuf4.Int64Value `protobuf:"bytes,5,opt,name=i64" json:"i64,omitempty"`
+ U64 *google_protobuf4.UInt64Value `protobuf:"bytes,6,opt,name=u64" json:"u64,omitempty"`
+ I32 *google_protobuf4.Int32Value `protobuf:"bytes,7,opt,name=i32" json:"i32,omitempty"`
+ U32 *google_protobuf4.UInt32Value `protobuf:"bytes,8,opt,name=u32" json:"u32,omitempty"`
+ Bool *google_protobuf4.BoolValue `protobuf:"bytes,9,opt,name=bool" json:"bool,omitempty"`
+ Str *google_protobuf4.StringValue `protobuf:"bytes,10,opt,name=str" json:"str,omitempty"`
+ Bytes *google_protobuf4.BytesValue `protobuf:"bytes,11,opt,name=bytes" json:"bytes,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *KnownTypes) Reset() { *m = KnownTypes{} }
+func (m *KnownTypes) String() string { return proto.CompactTextString(m) }
+func (*KnownTypes) ProtoMessage() {}
+func (*KnownTypes) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} }
+
+func (m *KnownTypes) GetAn() *google_protobuf.Any {
+ if m != nil {
+ return m.An
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetDur() *google_protobuf1.Duration {
+ if m != nil {
+ return m.Dur
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetSt() *google_protobuf2.Struct {
+ if m != nil {
+ return m.St
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetTs() *google_protobuf3.Timestamp {
+ if m != nil {
+ return m.Ts
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetDbl() *google_protobuf4.DoubleValue {
+ if m != nil {
+ return m.Dbl
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetFlt() *google_protobuf4.FloatValue {
+ if m != nil {
+ return m.Flt
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetI64() *google_protobuf4.Int64Value {
+ if m != nil {
+ return m.I64
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetU64() *google_protobuf4.UInt64Value {
+ if m != nil {
+ return m.U64
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetI32() *google_protobuf4.Int32Value {
+ if m != nil {
+ return m.I32
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetU32() *google_protobuf4.UInt32Value {
+ if m != nil {
+ return m.U32
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetBool() *google_protobuf4.BoolValue {
+ if m != nil {
+ return m.Bool
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetStr() *google_protobuf4.StringValue {
+ if m != nil {
+ return m.Str
+ }
+ return nil
+}
+
+func (m *KnownTypes) GetBytes() *google_protobuf4.BytesValue {
+ if m != nil {
+ return m.Bytes
+ }
+ return nil
+}
+
+var E_Name = &proto.ExtensionDesc{
+ ExtendedType: (*Real)(nil),
+ ExtensionType: (*string)(nil),
+ Field: 124,
+ Name: "jsonpb.name",
+ Tag: "bytes,124,opt,name=name",
+ Filename: "test_objects.proto",
+}
+
+func init() {
+ proto.RegisterType((*Simple)(nil), "jsonpb.Simple")
+ proto.RegisterType((*Repeats)(nil), "jsonpb.Repeats")
+ proto.RegisterType((*Widget)(nil), "jsonpb.Widget")
+ proto.RegisterType((*Maps)(nil), "jsonpb.Maps")
+ proto.RegisterType((*MsgWithOneof)(nil), "jsonpb.MsgWithOneof")
+ proto.RegisterType((*Real)(nil), "jsonpb.Real")
+ proto.RegisterType((*Complex)(nil), "jsonpb.Complex")
+ proto.RegisterType((*KnownTypes)(nil), "jsonpb.KnownTypes")
+ proto.RegisterEnum("jsonpb.Widget_Color", Widget_Color_name, Widget_Color_value)
+ proto.RegisterExtension(E_Complex_RealExtension)
+ proto.RegisterExtension(E_Name)
+}
+
+func init() { proto.RegisterFile("test_objects.proto", fileDescriptor1) }
+
+var fileDescriptor1 = []byte{
+ // 1054 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x95, 0xdf, 0x72, 0xdb, 0x44,
+ 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 0x69, 0x87, 0x07, 0xeb, 0x3b,
+ 0xc0, 0xe7, 0xe8, 0x57, 0x80, 0xcc, 0x40, 0x48, 0x1f, 0x13, 0xe7, 0x32, 0xd1, 0x78, 0x58, 0x70,
+ 0x35, 0x56, 0xf5, 0xf8, 0xb0, 0xe5, 0xf2, 0xcb, 0x44, 0x83, 0x3c, 0xce, 0x07, 0xce, 0x5d, 0x72,
+ 0x6c, 0xf6, 0x5c, 0x1e, 0x0f, 0x07, 0xb0, 0x9b, 0x6c, 0x38, 0xc0, 0x21, 0x74, 0xd7, 0x6e, 0xce,
+ 0x6f, 0xea, 0xb3, 0xe1, 0x00, 0xed, 0x0f, 0x43, 0x9c, 0x4c, 0x1b, 0xec, 0x0f, 0xc3, 0xc2, 0xfe,
+ 0x30, 0x44, 0xfb, 0xc3, 0x10, 0xc7, 0xd5, 0x26, 0xfb, 0x52, 0x9f, 0xa1, 0xbe, 0x86, 0xc3, 0xa6,
+ 0xb5, 0x01, 0x25, 0xdc, 0x36, 0x23, 0x47, 0x1d, 0xf8, 0xc3, 0xbb, 0x41, 0x36, 0xf8, 0x9b, 0x07,
+ 0x3c, 0xf7, 0x57, 0x5a, 0xd2, 0xaf, 0x49, 0xbd, 0x9a, 0x78, 0x77, 0x7d, 0x00, 0x3e, 0xec, 0xa6,
+ 0xc0, 0x28, 0x9f, 0xfa, 0xa4, 0x96, 0x46, 0x73, 0xbe, 0xd2, 0xa2, 0x7f, 0xe2, 0x5b, 0x80, 0x99,
+ 0x77, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7e, 0xe7, 0x47, 0x52, 0x0e, 0x09, 0x00, 0x00,
+}
diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto
new file mode 100644
index 000000000..d1934a074
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto
@@ -0,0 +1,135 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2015 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+import "google/protobuf/any.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+package jsonpb;
+
+// Test message for holding primitive types.
+message Simple {
+ optional bool o_bool = 1;
+ optional int32 o_int32 = 2;
+ optional int64 o_int64 = 3;
+ optional uint32 o_uint32 = 4;
+ optional uint64 o_uint64 = 5;
+ optional sint32 o_sint32 = 6;
+ optional sint64 o_sint64 = 7;
+ optional float o_float = 8;
+ optional double o_double = 9;
+ optional string o_string = 10;
+ optional bytes o_bytes = 11;
+}
+
+// Test message for holding repeated primitives.
+message Repeats {
+ repeated bool r_bool = 1;
+ repeated int32 r_int32 = 2;
+ repeated int64 r_int64 = 3;
+ repeated uint32 r_uint32 = 4;
+ repeated uint64 r_uint64 = 5;
+ repeated sint32 r_sint32 = 6;
+ repeated sint64 r_sint64 = 7;
+ repeated float r_float = 8;
+ repeated double r_double = 9;
+ repeated string r_string = 10;
+ repeated bytes r_bytes = 11;
+}
+
+// Test message for holding enums and nested messages.
+message Widget {
+ enum Color {
+ RED = 0;
+ GREEN = 1;
+ BLUE = 2;
+ };
+ optional Color color = 1;
+ repeated Color r_color = 2;
+
+ optional Simple simple = 10;
+ repeated Simple r_simple = 11;
+
+ optional Repeats repeats = 20;
+ repeated Repeats r_repeats = 21;
+}
+
+message Maps {
+ map<int64, string> m_int64_str = 1;
+ map<bool, Simple> m_bool_simple = 2;
+}
+
+message MsgWithOneof {
+ oneof union {
+ string title = 1;
+ int64 salary = 2;
+ string Country = 3;
+ string home_address = 4;
+ }
+}
+
+message Real {
+ optional double value = 1;
+ extensions 100 to max;
+}
+
+extend Real {
+ optional string name = 124;
+}
+
+message Complex {
+ extend Real {
+ optional Complex real_extension = 123;
+ }
+ optional double imaginary = 1;
+ extensions 100 to max;
+}
+
+message KnownTypes {
+ optional google.protobuf.Any an = 14;
+ optional google.protobuf.Duration dur = 1;
+ optional google.protobuf.Struct st = 12;
+ 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;
+}