Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf3 default JSON encoding #44

Closed
philips opened this issue Jun 26, 2015 · 5 comments
Closed

protobuf3 default JSON encoding #44

philips opened this issue Jun 26, 2015 · 5 comments
Assignees

Comments

@philips
Copy link

philips commented Jun 26, 2015

In the proto3 there are encodings for different types, in particular the Timestamp type. Where is that code implemented? I am having a hard time figuring it out. https://developers.google.com/protocol-buffers/docs/proto3#json

cc @sym3tri

@dsymonds
Copy link
Contributor

dsymonds commented Jul 1, 2015

The newly added jsonpb package (see 67cbcad) is the official vehicle for JSON support. There's not yet any support for Timestamp and friends yet.

@philips
Copy link
Author

philips commented Jul 1, 2015

Thank you for the update!

wking added a commit to wking/opencontainer-runtime-spec that referenced this issue Sep 26, 2015
Using jsonpb [1,2].

Drop the proto.String bits to avoid errors like:

  ./example.go:17: cannot use proto.String("linux") (type *string) as
    type string in field value

And use a reference to s to avoid:

  ./example.go:29: cannot use s (type oci.LinuxSpec) as type
     proto.Message in argument to marshaler.Marshal: oci.LinuxSpec
     does not implement proto.Message (ProtoMessage method has pointer
     receiver)

[1]: golang/protobuf#44
[2]: http://godoc.org/github.com/golang/protobuf/jsonpb

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this issue Sep 29, 2015
Using jsonpb [1,2].

Drop the proto.String bits to avoid errors like:

  ./example.go:17: cannot use proto.String("linux") (type *string) as
    type string in field value

And use a reference to s to avoid:

  ./example.go:29: cannot use s (type oci.LinuxSpec) as type
     proto.Message in argument to marshaler.Marshal: oci.LinuxSpec
     does not implement proto.Message (ProtoMessage method has pointer
     receiver)

[1]: golang/protobuf#44
[2]: http://godoc.org/github.com/golang/protobuf/jsonpb

Signed-off-by: W. Trevor King <wking@tremily.us>
@dsymonds dsymonds self-assigned this Feb 25, 2016
@dsymonds
Copy link
Contributor

553c764 adds jsonpb support for Duration and Timestamp according to the spec. Other types will follow.

@dsymonds
Copy link
Contributor

c6184d3 adds jsonpb support for the types in wrappers.proto.

@dsymonds
Copy link
Contributor

552c7b9 adds jsonpb support for Struct and NullValue.

I think that's all we have covered right now.

@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants