is the scalapb.json4s.JsonFormat.toJsonString canonical format?

15 views
Skip to first unread message

Zohar Etzioni

unread,
Feb 13, 2019, 7:01:16 PM2/13/19
to ScalaPB
Hello, 

I'm looking to get a json canonical form from a generated proto (with scalapb). Would toJsonString return a canonical form?

Thanks,
Z

Nadav Samet

unread,
Feb 13, 2019, 7:31:50 PM2/13/19
to Zohar Etzioni, ScalaPB
Hi Zohar, ScalaPB creates and parses JSON that conforms to the mapping described here: https://developers.google.com/protocol-buffers/docs/proto3#json

If you mean canonical form as what described in this draft, then I suspect the answer would be no - ScalaPB delegates to json4s which I don't believe has this guarantee.

-Nadav

--
You received this message because you are subscribed to the Google Groups "ScalaPB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalapb+u...@googlegroups.com.
To post to this group, send email to sca...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalapb/0a17d2c9-50b3-4858-8bb6-048ac6a1f7b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-Nadav

Zohar Etzioni

unread,
Feb 14, 2019, 1:49:37 AM2/14/19
to Nadav Samet, ScalaPB
Thanks Nadav. The purpose I need the canonical form is as described in the RFC, i.e. for signing/verifying protobuf messages across different machines and programming languages. The proto3 spec states that it supports canonical encoding in json, so I wonder if this is sufficient for this purpose. 

Thanks,
Z

Nadav Samet

unread,
Feb 14, 2019, 11:55:25 AM2/14/19
to Zohar Etzioni, ScalaPB
I'm not 100% sure that the proto3 spec uses the word canonical in the sense of the RFC - it's worth asking this question on Google Protobuf mailing list, and if you determine that the answer is yes, then you should use the Java JSON conversion, since it is a different implementation than the JSON implementation that ScalaPB provides.

-Nadav
--
-Nadav

Zohar Etzioni

unread,
Feb 14, 2019, 12:11:45 PM2/14/19
to Nadav Samet, ScalaPB
Done, thanks!
Reply all
Reply to author
Forward
0 new messages