Help Needed !! How to get proper hex value of serialized stream

38 views
Skip to first unread message

arun kumar

unread,
Sep 5, 2019, 2:17:38 AM9/5/19
to Protocol Buffers
I am trying to serialize the data using C# Google protobuf, and I am using below code ,

private static void printStream(IMessage msg)
       
{


           
int size = msg.CalculateSize();
           
byte[] buffer = new byte[size];
           
CodedOutputStream output = new CodedOutputStream(buffer);
            msg
.WriteTo(output);
           
foreach (byte bb in buffer)
           
{
               
Console.Write(bb);
           
}
       
}

JSON of IMessage Object is

{
 
"clientIdentifier": {
   
"context": "CFID",
   
"value": "12340000"
 
},
 
"desiredSessionTimeout": "30000"
}


When I print the bytes, I am getting ::   1081862151092482117752161762341..  I believe, it is giving dec value whereas I am expecting hex value : 0a0a1208313233343030303010b0ea01. 

Please help me out , how to get the hex value.. 

Nadav Samet

unread,
Sep 5, 2019, 8:33:44 AM9/5/19
to arun kumar, Protocol Buffers

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/14bd44ad-10e4-4398-911f-efddad5cbc56%40googlegroups.com.


--
-Nadav

Arun

unread,
Sep 6, 2019, 2:48:24 AM9/6/19
to Nadav Samet, Protocol Buffers
Thanks Nadav. It worked for conversion of byte. 

But, my actual problem seems like different and  I was at wrong place in debugging.,  
I have posted the actual issue here  .,  https://groups.google.com/d/msg/protobuf/kvS7WyNATTw/etbZM3R5AAAJ . It will really helpful if you can look into it 
--
-- Arun

Reply all
Reply to author
Forward
0 new messages