Re: [protobuf] Re: Converting JSON Text Into PB Bytes Type

2011-01-05 Thread Siju Varghese
It is a stable branch. Please raise any issues at
https://github.com/sijuv/protobuf-codec/issues

Regards,
Siju


On Wed, Jan 5, 2011 at 2:22 PM, yalmasri  wrote:

> Used the HTTP URL and it worked like charm. Now building resulted in a
> compilation failure, it's saying:
>
> \GIT\protobuf-codec\protobuf-codec-json\src\test\java\protobuf\codec
> \json\TypesP
> rotoBuf.java:[2860,48] newGeneratedExtension() in
> com.googl
> e.protobuf.GeneratedMessage cannot be applied to
> (com.google.protobuf.Descriptor
> s.FieldDescriptor,java.lang.Class)
> \GIT\protobuf-codec\protobuf-codec-json\src\test\java\protobuf\codec
> \json\TypesP
> rotoBuf.java:[2865,14] cannot find symbol
> symbol  : method
> newRepeatedGeneratedExtension(com.google.protobuf.Descriptors.F
> ieldDescriptor,java.lang.Class)
> location: class com.google.protobuf.GeneratedMessage
> \GIT\protobuf-codec\protobuf-codec-json\src\test\java\protobuf\codec
> \json\TypesP
> rotoBuf.java:[2870,14] cannot find symbol
> symbol  : method
> newRepeatedGeneratedExtension(com.google.protobuf.Descriptors.F
> ieldDescriptor,java.lang.Class)
> location: class com.google.protobuf.GeneratedMessage
>
> Did I retrieve a development branch or something?
>
>
> On Jan 5, 11:32 am, yalmasri  wrote:
> > 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  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  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  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
> > > > > Java".
> >
> > > > > Let me know if you run into any issues.
> >
> > > > > Regards.
> >
> > > > > On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda 
> 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 
> 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  wrote:
> > > > > >> > You will probably need to base64-encode bytes fields before
> > > > embedding
> > > > > >> them
> > > > > >> > in JSON, since JSON is a text format.
> >
> > > > > >> > W

[protobuf] Re: Converting JSON Text Into PB Bytes Type

2011-01-05 Thread yalmasri
Used the HTTP URL and it worked like charm. Now building resulted in a
compilation failure, it's saying:

\GIT\protobuf-codec\protobuf-codec-json\src\test\java\protobuf\codec
\json\TypesP
rotoBuf.java:[2860,48] newGeneratedExtension() in
com.googl
e.protobuf.GeneratedMessage cannot be applied to
(com.google.protobuf.Descriptor
s.FieldDescriptor,java.lang.Class)
\GIT\protobuf-codec\protobuf-codec-json\src\test\java\protobuf\codec
\json\TypesP
rotoBuf.java:[2865,14] cannot find symbol
symbol  : method
newRepeatedGeneratedExtension(com.google.protobuf.Descriptors.F
ieldDescriptor,java.lang.Class)
location: class com.google.protobuf.GeneratedMessage
\GIT\protobuf-codec\protobuf-codec-json\src\test\java\protobuf\codec
\json\TypesP
rotoBuf.java:[2870,14] cannot find symbol
symbol  : method
newRepeatedGeneratedExtension(com.google.protobuf.Descriptors.F
ieldDescriptor,java.lang.Class)
location: class com.google.protobuf.GeneratedMessage

Did I retrieve a development branch or something?


On Jan 5, 11:32 am, yalmasri  wrote:
> 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  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  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  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
> > > > Java".
>
> > > > Let me know if you run into any issues.
>
> > > > Regards.
>
> > > > On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda  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  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  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 
> > > 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 t

[protobuf] Re: Converting JSON Text Into PB Bytes Type

2011-01-05 Thread yalmasri
used the HTTP URL and it worked fine. That's much easier than going
into the hassles of TortoiseGit and the rest of nasty SSH stuff.

Anyway, trying to build it resulted in:

[INFO]

[ERROR] BUILD ERROR
[INFO]

[INFO] Cannot execute mojo: resources. It requires a project with an
existing po
m.xml, but the build is not using one.
[INFO]

[INFO] For more information, run Maven with the -e switch
[INFO]

[INFO] Total time: 3 seconds
[INFO] Finished at: Wed Jan 05 11:36:03 AST 2011
[INFO] Final Memory: 4M/15M
[INFO]


On Jan 5, 11:32 am, yalmasri  wrote:
> 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  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  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  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
> > > > Java".
>
> > > > Let me know if you run into any issues.
>
> > > > Regards.
>
> > > > On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda  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  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  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 
> > > 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 f

[protobuf] Re: Converting JSON Text Into PB Bytes Type

2011-01-05 Thread yalmasri
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  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  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  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
> > > Java".
>
> > > Let me know if you run into any issues.
>
> > > Regards.
>
> > > On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda  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  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  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 
> > 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.com
> > 
>
> > > >> 
> > 
>
> > > >> > > .
> > > >> > > For more options, visit this group at
> > > >> > >http://groups.google.com/group/pro

[protobuf] Re: Converting JSON Text Into PB Bytes Type

2011-01-04 Thread yalmasri
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  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
> Java".
>
> Let me know if you run into any issues.
>
> Regards.
>
> On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda  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  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  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  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.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.
>
> >  --
> > 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.

-- 
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

2011-01-03 Thread Siju Varghese
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
Java".


Let me know if you run into any issues.

Regards.

On Wed, Dec 29, 2010 at 4:34 AM, Kenton Varda  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  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  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  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.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.
>>
>>
>  --
> 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.
>

-- 
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

2010-12-28 Thread Kenton Varda
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  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  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  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.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.
>
>

-- 
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.



[protobuf] Re: Converting JSON Text Into PB Bytes Type

2010-12-25 Thread yalmasri
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  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  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.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.