Will protobuf support JSON?

1,607 views
Skip to first unread message

ZHOU Xiaobo

unread,
Apr 1, 2011, 11:08:00 AM4/1/11
to Protocol Buffers
script languages can easily dealing with JSON, but
in C/C++ is actually difficult.
can protobuf support json encode/decode?

Konrad Malawski

unread,
Apr 1, 2011, 11:19:39 AM4/1/11
to ZHOU Xiaobo, Protocol Buffers
Sure, just google "protobuf json" -> http://code.google.com/p/protobuf-json/
-- 
Konrad Malawski
XSolve.pl - Software Developer
Java.pl - Polish Java User Group
Project13.pl - Private Portfolio & Blog


2011/4/1 ZHOU Xiaobo <xb....@qq.com>
script languages can easily dealing with JSON, but
in C/C++ is actually difficult.
can protobuf support json encode/decode?

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Austin Ziegler

unread,
Apr 1, 2011, 4:32:42 PM4/1/11
to Protocol Buffers, ZHOU Xiaobo, Konrad Malawski
On Fri, Apr 1, 2011 at 11:19 AM, Konrad Malawski
<konrad....@project13.pl> wrote:
> Sure, just google "protobuf json" -> http://code.google.com/p/protobuf-json/

> 2011/4/1 ZHOU Xiaobo <xb....@qq.com>


>>
>> script languages can easily dealing with JSON, but
>> in C/C++ is actually difficult.
>> can protobuf support json encode/decode?

A few weeks ago, someone on my team wrote something in Ruby to
generate the .proto file that would be associated with the JSON that
we're expecting, plus the necessary YAJL code to parse the JSON in
C++.

It's not that hard to do, but we can't open source our work (it's too
raw in any case).

-a
--
Austin Ziegler • halos...@gmail.comaus...@halostatue.ca
http://www.halostatue.ca/http://twitter.com/halostatue

Mikhail Melnik

unread,
May 12, 2015, 12:56:29 PM5/12/15
to prot...@googlegroups.com, halos...@gmail.com, konrad....@project13.pl, xb....@qq.com
There is mention in official documentation https://developers.google.com/protocol-buffers/docs/proto3#json
that says JSON encoding/decoding is supported by prtotobuf.

But in release notes https://github.com/google/protobuf/releases it is said
that json encoding should be implemented in 3 version of protocol.
Also there is no json encoder/formatter in source code.

So it's not clear for me is it implemented or not? In case it's not, will it be implemented in the future?

If this functionality already exists does any one can provide example how to make such conversion?
I'm especially interesting in Java implementation of protobuf -> json conversion and vice verse.

If any one has information on topic I would be very grateful.

Feng Xiao

unread,
May 12, 2015, 2:56:16 PM5/12/15
to Mikhail Melnik, Protocol Buffers, halos...@gmail.com, konrad....@project13.pl, xb....@qq.com
On Tue, May 12, 2015 at 9:56 AM, Mikhail Melnik <mikhail...@teamdev.com> wrote:
There is mention in official documentation https://developers.google.com/protocol-buffers/docs/proto3#json
that says JSON encoding/decoding is supported by prtotobuf.

But in release notes https://github.com/google/protobuf/releases it is said
that json encoding should be implemented in 3 version of protocol.
Also there is no json encoder/formatter in source code.

So it's not clear for me is it implemented or not?
It's not implemented yet.
 
In case it's not, will it be implemented in the future?
Yes.
 

If this functionality already exists does any one can provide example how to make such conversion?
I'm especially interesting in Java implementation of protobuf -> json conversion and vice verse.
We will provide an utility class that converts between protobuf binary format and JSON. The API will look like this:
class JsonFormat {
  void convertBinaryToJson(TypeResolver typeResolver, InputStream binaryInput, Writer jsonOutput);
}
interface TypeResolver {
  com.google.protobuf.Type resolveMessageType(String typeUrl);
  com.google.protobuf.Enum resolveEnumType(String typeUrl);
}

The JSON output will follow the spec described in the proto3 developer guide.

 

If any one has information on topic I would be very grateful.


On Friday, April 1, 2011 at 11:32:42 PM UTC+3, Austin Ziegler wrote:
On Fri, Apr 1, 2011 at 11:19 AM, Konrad Malawski
<konrad....@project13.pl> wrote:
> Sure, just google "protobuf json" -> http://code.google.com/p/protobuf-json/

> 2011/4/1 ZHOU Xiaobo <xb....@qq.com>
>>
>> script languages can easily dealing with JSON, but
>> in C/C++ is actually difficult.
>> can protobuf support json encode/decode?

A few weeks ago, someone on my team wrote something in Ruby to
generate the .proto file that would be associated with the JSON that
we're expecting, plus the necessary YAJL code to parse the JSON in
C++.

It's not that hard to do, but we can't open source our work (it's too
raw in any case).

-a
--
Austin Ziegler • halos...@gmail.comaus...@halostatue.ca
http://www.halostatue.ca/http://twitter.com/halostatue

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.

To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Mikhail Melnik

unread,
May 13, 2015, 7:38:57 AM5/13/15
to prot...@googlegroups.com
Thank you for a fast and clear answer!

Giri Guntipalli

unread,
May 15, 2015, 4:25:33 AM5/15/15
to prot...@googlegroups.com
JSON conversion utility function is expected to be compatible with proto-lite library?

Feng Xiao

unread,
May 15, 2015, 1:35:57 PM5/15/15
to Giri Guntipalli, Protocol Buffers
On Fri, May 15, 2015 at 1:25 AM, Giri Guntipalli <giri.gu...@gmail.com> wrote:
JSON conversion utility function is expected to be compatible with proto-lite library?
These functions will only be available in the full run-time.

Alfred Kwan

unread,
Jul 15, 2016, 4:11:40 PM7/15/16
to Protocol Buffers, mikhail...@teamdev.com, halos...@gmail.com, konrad....@project13.pl, xb....@qq.com
I looked at the 3.0 beta package and I believe the JSON support is not in yet. Am I correct?

Feng Xiao

unread,
Jul 15, 2016, 6:39:26 PM7/15/16
to Alfred Kwan, Protocol Buffers, Mikhail Melnik, Austin Ziegler, Konrad Malawski, xb....@qq.com
On Fri, Jul 15, 2016 at 1:11 PM, Alfred Kwan <alfr...@gmail.com> wrote:
I looked at the 3.0 beta package and I believe the JSON support is not in yet. Am I correct?
What package are you looking at? For Java, the JSON support is in the protobuf-java-util maven package.
 

Alfred Kwan

unread,
Jul 20, 2016, 8:23:04 AM7/20/16
to Protocol Buffers, alfr...@gmail.com, mikhail...@teamdev.com, halos...@gmail.com, konrad....@project13.pl, xb....@qq.com
I use the C++ package.

Feng Xiao

unread,
Jul 20, 2016, 4:13:49 PM7/20/16
to Alfred Kwan, Protocol Buffers, Mikhail Melnik, Austin Ziegler, Konrad Malawski, xb....@qq.com


On Wed, Jul 20, 2016 at 5:23 AM, Alfred Kwan <alfr...@gmail.com> wrote:
I use the C++ package.
For C++, you can use the utility functions declared here:

Alfred Kwan

unread,
Jul 29, 2016, 1:50:22 PM7/29/16
to Protocol Buffers, alfr...@gmail.com, mikhail...@teamdev.com, halos...@gmail.com, konrad....@project13.pl, xb....@qq.com
I can see it now, thank you.

Btw congrats on the official 3.0 release! Good work indeed.
Reply all
Reply to author
Forward
0 new messages