[protobuf] Re: Converting JSON Text Into PB Bytes Type
Appreciate the swift response! Forgive my ignorance in GIT, but I've got this when I ran the command: git clone git://github.com/sijuv/protobuf-codec.git Cloning into protobuf-codec... github.com[0: 207.97.227.239]: errno=No error fatal: unable to connect a socket (No error) I could ping the above IP without any issue. Is the reason for this error apparent to you? On Jan 5, 11:18 am, Siju Varghese varghese.s...@gmail.com wrote: protobuf.codec.json.TypesProtoBuf is generated at build time through protoc. You can use the file that I have attached. To clone the git project : - Install the git s/whttp://git-scm.com/ - clone the project from git://github.com/sijuv/protobuf-codec.git - git clone git://github.com/sijuv/protobuf-codec.git - mvn clean install to build the project [ this will generate the missing files ] Regards, Siju On Wed, Jan 5, 2011 at 1:15 PM, yalmasri y.alma...@gmail.com wrote: Thanks. I downloaded the binaries and tried to use the test class but my compiler couldn't see class protobuf.codec.json.TypesProtoBuf, it's not anywhere in the binaries. Has this class been added recently but was not reflected to the binaries? I also tried to download source, but seems like GIT is very tedious to configure. On Jan 3, 8:47 pm, Siju Varghese varghese.s...@gmail.com wrote: You could usehttps://github.com/sijuv/protobuf-codec. You can check the test case athttps:// github.com/sijuv/protobuf-codec/blob/master/protobuf-codec-js... usage. This library is listed under the google protobuf ThirdPartyAddOns wiki as Another JSON encoder/decoder for Javahttps://github.com/sijuv/protobuf-codec. Let me know if you run into any issues. Regards. On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda ken...@google.com wrote: You should probably contact the authors of protobuf-java-format; I'm not sure if they pay attention to this list. Base64 is the best way to encode arbitrary (non-text) data as text. However, it's really up to the JSON converter code you are using to decide what format to use. As far as I know, JSON does not specify any particular encoding for arbitrary bytes. On Sat, Dec 25, 2010 at 2:40 AM, yalmasri y.alma...@gmail.com wrote: Thanks for the reply. I encoded Hello world in Base64 and I got this SGVsbG8gd29ybGQ=. That doesn't look close to the format I sent in the question. Here's the code snippet I used: import org.apache.commons.codec.binary.Base64; public class Codec { public static void main(String[] args) { try { String clearText = Hello world; // Base64 System.out.println(Encoded: + Base64.encodeBase64String(clearText.getBytes())); } catch (Exception e) { e.printStackTrace(); } } } I'm using this:http://code.google.com/p/protobuf-java-format/for JSON -- PB conversion On Dec 23, 3:48 am, Kenton Varda ken...@google.com wrote: You will probably need to base64-encode bytes fields before embedding them in JSON, since JSON is a text format. Which JSON - protobuf converter are you using? Or did you write your own? On Tue, Dec 21, 2010 at 11:41 PM, yalmasri y.alma...@gmail.com wrote: Hello, One of our customers is still using legacy Java 1.4 and therefore could not use PB. For that we created an intermediate service that receives text messages in plain JSON format then convert them into generated PB objects. In one object we have a field named desc of type bytes which will hold a textual description of the arriving message. When the customer wants to send English text for desc the value in JSON will be plain readable English, but if non-ASCII is to be used, how the value in JSON will look like? It look to me something like: \0069\0062\006J\0062\006J\000 \006\'\006D\0069\006E\006J\006D\006\f \000 \006D\006B\006/\000 \006\'\006F\006*\006G\006I\000 But I really don't know how to get this out of non-ASCII characters. Can anyone help? -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com protobuf%2bunsubscr...@googlegroups.comprotobuf%252bunsubscr...@googlegroups.com protobuf%2bunsubscr...@googlegroups.comprotobuf%252bunsubscr...@googlegroups.com protobuf%252bunsubscr...@googlegroups.comprotobuf%25252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this
[protobuf] Re: Converting JSON Text Into PB Bytes Type
Thanks. I downloaded the binaries and tried to use the test class but my compiler couldn't see class protobuf.codec.json.TypesProtoBuf, it's not anywhere in the binaries. Has this class been added recently but was not reflected to the binaries? I also tried to download source, but seems like GIT is very tedious to configure. On Jan 3, 8:47 pm, Siju Varghese varghese.s...@gmail.com wrote: You could usehttps://github.com/sijuv/protobuf-codec. You can check the test case athttps://github.com/sijuv/protobuf-codec/blob/master/protobuf-codec-js... usage. This library is listed under the google protobuf ThirdPartyAddOns wiki as Another JSON encoder/decoder for Javahttps://github.com/sijuv/protobuf-codec. Let me know if you run into any issues. Regards. On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda ken...@google.com wrote: You should probably contact the authors of protobuf-java-format; I'm not sure if they pay attention to this list. Base64 is the best way to encode arbitrary (non-text) data as text. However, it's really up to the JSON converter code you are using to decide what format to use. As far as I know, JSON does not specify any particular encoding for arbitrary bytes. On Sat, Dec 25, 2010 at 2:40 AM, yalmasri y.alma...@gmail.com wrote: Thanks for the reply. I encoded Hello world in Base64 and I got this SGVsbG8gd29ybGQ=. That doesn't look close to the format I sent in the question. Here's the code snippet I used: import org.apache.commons.codec.binary.Base64; public class Codec { public static void main(String[] args) { try { String clearText = Hello world; // Base64 System.out.println(Encoded: + Base64.encodeBase64String(clearText.getBytes())); } catch (Exception e) { e.printStackTrace(); } } } I'm using this:http://code.google.com/p/protobuf-java-format/for JSON -- PB conversion On Dec 23, 3:48 am, Kenton Varda ken...@google.com wrote: You will probably need to base64-encode bytes fields before embedding them in JSON, since JSON is a text format. Which JSON - protobuf converter are you using? Or did you write your own? On Tue, Dec 21, 2010 at 11:41 PM, yalmasri y.alma...@gmail.com wrote: Hello, One of our customers is still using legacy Java 1.4 and therefore could not use PB. For that we created an intermediate service that receives text messages in plain JSON format then convert them into generated PB objects. In one object we have a field named desc of type bytes which will hold a textual description of the arriving message. When the customer wants to send English text for desc the value in JSON will be plain readable English, but if non-ASCII is to be used, how the value in JSON will look like? It look to me something like: \0069\0062\006J\0062\006J\000 \006\'\006D\0069\006E\006J\006D\006\f \000 \006D\006B\006/\000 \006\'\006F\006*\006G\006I\000 But I really don't know how to get this out of non-ASCII characters. Can anyone help? -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com protobuf%2bunsubscr...@googlegroups.comprotobuf%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Re: Converting JSON Text Into PB Bytes Type
You could use https://github.com/sijuv/protobuf-codec . You can check the test case at https://github.com/sijuv/protobuf-codec/blob/master/protobuf-codec-json/src/test/java/protobuf/codec/json/JsonCodecTest.javafor usage. This library is listed under the google protobuf ThirdPartyAddOns wiki as Another JSON encoder/decoder for Javahttps://github.com/sijuv/protobuf-codec. Let me know if you run into any issues. Regards. On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda ken...@google.com wrote: You should probably contact the authors of protobuf-java-format; I'm not sure if they pay attention to this list. Base64 is the best way to encode arbitrary (non-text) data as text. However, it's really up to the JSON converter code you are using to decide what format to use. As far as I know, JSON does not specify any particular encoding for arbitrary bytes. On Sat, Dec 25, 2010 at 2:40 AM, yalmasri y.alma...@gmail.com wrote: Thanks for the reply. I encoded Hello world in Base64 and I got this SGVsbG8gd29ybGQ=. That doesn't look close to the format I sent in the question. Here's the code snippet I used: import org.apache.commons.codec.binary.Base64; public class Codec { public static void main(String[] args) { try { String clearText = Hello world; // Base64 System.out.println(Encoded: + Base64.encodeBase64String(clearText.getBytes())); } catch (Exception e) { e.printStackTrace(); } } } I'm using this: http://code.google.com/p/protobuf-java-format/ for JSON -- PB conversion On Dec 23, 3:48 am, Kenton Varda ken...@google.com wrote: You will probably need to base64-encode bytes fields before embedding them in JSON, since JSON is a text format. Which JSON - protobuf converter are you using? Or did you write your own? On Tue, Dec 21, 2010 at 11:41 PM, yalmasri y.alma...@gmail.com wrote: Hello, One of our customers is still using legacy Java 1.4 and therefore could not use PB. For that we created an intermediate service that receives text messages in plain JSON format then convert them into generated PB objects. In one object we have a field named desc of type bytes which will hold a textual description of the arriving message. When the customer wants to send English text for desc the value in JSON will be plain readable English, but if non-ASCII is to be used, how the value in JSON will look like? It look to me something like: \0069\0062\006J\0062\006J\000 \006\'\006D\0069\006E\006J\006D\006\f \000 \006D\006B\006/\000 \006\'\006F\006*\006G\006I\000 But I really don't know how to get this out of non-ASCII characters. Can anyone help? -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com protobuf%2bunsubscr...@googlegroups.comprotobuf%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Re: Converting JSON Text Into PB Bytes Type
You should probably contact the authors of protobuf-java-format; I'm not sure if they pay attention to this list. Base64 is the best way to encode arbitrary (non-text) data as text. However, it's really up to the JSON converter code you are using to decide what format to use. As far as I know, JSON does not specify any particular encoding for arbitrary bytes. On Sat, Dec 25, 2010 at 2:40 AM, yalmasri y.alma...@gmail.com wrote: Thanks for the reply. I encoded Hello world in Base64 and I got this SGVsbG8gd29ybGQ=. That doesn't look close to the format I sent in the question. Here's the code snippet I used: import org.apache.commons.codec.binary.Base64; public class Codec { public static void main(String[] args) { try { String clearText = Hello world; // Base64 System.out.println(Encoded: + Base64.encodeBase64String(clearText.getBytes())); } catch (Exception e) { e.printStackTrace(); } } } I'm using this: http://code.google.com/p/protobuf-java-format/ for JSON -- PB conversion On Dec 23, 3:48 am, Kenton Varda ken...@google.com wrote: You will probably need to base64-encode bytes fields before embedding them in JSON, since JSON is a text format. Which JSON - protobuf converter are you using? Or did you write your own? On Tue, Dec 21, 2010 at 11:41 PM, yalmasri y.alma...@gmail.com wrote: Hello, One of our customers is still using legacy Java 1.4 and therefore could not use PB. For that we created an intermediate service that receives text messages in plain JSON format then convert them into generated PB objects. In one object we have a field named desc of type bytes which will hold a textual description of the arriving message. When the customer wants to send English text for desc the value in JSON will be plain readable English, but if non-ASCII is to be used, how the value in JSON will look like? It look to me something like: \0069\0062\006J\0062\006J\000 \006\'\006D\0069\006E\006J\006D\006\f \000 \006D\006B\006/\000 \006\'\006F\006*\006G\006I\000 But I really don't know how to get this out of non-ASCII characters. Can anyone help? -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com protobuf%2bunsubscr...@googlegroups.comprotobuf%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.