Hi,

Does anyone have JsonFormat class for ProtocolBuffers in Java? Why
would this be useful? It would mean that that you could make rpc calls
from javascript to your web service that you implemented using
protocol buffers and jetty.

As an example lets say you have a message with type:

message Person {
  required string name = 1;
  repeated string phoneNumber = 2;
}

Examples of this message in Json are:

{ name: "Richard" }
{ name: "Richard", phone: [ "555-555-111" ] }

See that repeated fields become lists. That repeated fields don't have
to be present if they're empty. The Json format doesn't have field
numbers. Our purpose is not to make the Json messages compact, it is
to make it easy to use them from javascript.

Embedded message work as you would expect:

message Person {
  required string name = 1;
  repeated string phoneNumber = 2;
  repeated Address address = 3;
}

message Address {
  required string addrLine1 = 1;
  optional string addrLine2 = 2;
  required string state       = 3;
}

Then the Json is

{ name: "Richard", phoneNumber: [ "555-555-555" ], address:
{ addrLine1 = "12 Somestreet", state = "ZZ" } }

regards,

Richard.


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

Reply via email to