jsonFormat.printToString escaping bytes fields

202 views
Skip to first unread message

bjuhn

unread,
Jun 28, 2012, 9:33:42 PM6/28/12
to protobuf-j...@googlegroups.com
Hi There,

I'm using jsonFormat.printToString(message) and I'm finding that my byte fields are invalid json.  The resulting strings container single escapes rather than double... i.e. "\v\u0018\uffd8\uffb0\uffe3\uffb4\u0002"

Shouldn't these be double escaped?

Thanks!

Philippe Laflamme

unread,
Jun 29, 2012, 5:15:51 AM6/29/12
to bjuhn, protobuf-j...@googlegroups.com
That depends on your original string. I'm not sure why you're getting a "\v" in your resulting string, that's not valid. Otherwise, everything else in your string is valid...

Philippe

--
You received this message because you are subscribed to the Google Groups "protobuf-java-format" group.
To view this discussion on the web visit https://groups.google.com/d/msg/protobuf-java-format/-/UijjCPhAiukJ.
To post to this group, send email to protobuf-j...@googlegroups.com.
To unsubscribe from this group, send email to protobuf-java-fo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf-java-format?hl=en.

bjuhn

unread,
Jun 29, 2012, 1:14:30 PM6/29/12
to protobuf-j...@googlegroups.com
My understanding is that it should be escaping all control characters which includes \uxxxx.  Jquery fails on $.parseJSON('["\u0018"\').  Should I file a bug for this?

Thanks,
Ben


On Friday, 29 June 2012 02:15:51 UTC-7, Philippe Laflamme wrote:
That depends on your original string. I'm not sure why you're getting a "\v" in your resulting string, that's not valid. Otherwise, everything else in your string is valid...

Philippe

On Thu, Jun 28, 2012 at 9:33 PM, bjuhn wrote:
Hi There,

I'm using jsonFormat.printToString(message) and I'm finding that my byte fields are invalid json.  The resulting strings container single escapes rather than double... i.e. "\v\u0018\uffd8\uffb0\uffe3\uffb4\u0002"

Shouldn't these be double escaped?

Thanks!

--
You received this message because you are subscribed to the Google Groups "protobuf-java-format" group.
To view this discussion on the web visit https://groups.google.com/d/msg/protobuf-java-format/-/UijjCPhAiukJ.
To post to this group, send email to protobuf-java-format@googlegroups.com.
To unsubscribe from this group, send email to protobuf-java-format+unsub...@googlegroups.com.

David Roid

unread,
Aug 30, 2012, 7:04:02 AM8/30/12
to protobuf-j...@googlegroups.com

在 2012年6月29日星期五UTC+8上午9时33分42秒,bjuhn写道:

pacll

unread,
Sep 14, 2012, 12:48:57 PM9/14/12
to protobuf-j...@googlegroups.com, bjuhn
I know this thread is a little old.  For anyone stumbling upon this discussion in the future, you may want to look at issue #43 which I filed today on bugs page.
The current (1.2 release) source clearly handles 0x0007 and 0x000b improperly and emits "\a" and "\v" in JSON output string literals.
Reply all
Reply to author
Forward
0 new messages