Reading encoded msg from cassandra and try to decode

6 views
Skip to first unread message

Lisa W

unread,
Mar 4, 2019, 8:44:55 PM3/4/19
to ScalaPB
I'm connecting to Cassadra db to read some data, and one of the filed is encoded msg from protobuf in hex (example below). How can I convert them back to the original json string? 

for example the hex msg like: "0A1D756D632E6372712E317A6A6F65643963617632773179716E386965777710011893FCB38BF52920012A0F79623A757365723A3231303138303132327B22646973706C61794E616D65223A2256697267696E696A61205065747275736F6E652028767065747275736F6E6529227D42620802AA065D0A21756D632E636D632E31766F3863666F71356262696962323135626C726E787370771228756D632E636D722E6974732E6D762E3531716C683261386B697872737672376D386F7472763367351A0E080512085374616E646172641A004A0E0893FCB38BF5291093FCB38BF529"

many thanks!

L.W.

Nadav Samet

unread,
Mar 5, 2019, 1:28:49 AM3/5/19
to Lisa W, ScalaPB
Hi Lisa,

You can use something like org.apache.commons.codec.binary.Hex to convert the hex string into a byte array, and then decode it using the protobuf message's parseFrom method.

-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/c5cb0f20-a303-42da-a57d-78034c127520%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-Nadav
Reply all
Reply to author
Forward
0 new messages