Is protojson converted to binary inside the runtime?

I was reading the project template for XOXO and I saw that the match status was marshalled using protojson

however, as I understand protojson just creates json instead of a binary protobuf.

Is the binary marshalling done inside the runtime and hidden from the user or should I move to the proto.Marshal marshaller to take advantage of the binary goodness of protobuf?

Sorry if this is a silly question, I understand the idea of protobufs but haven’t worked with them yet :sweat_smile:


edit:

Reading how the client js implementation works, it seems that the entire match status is a string in a bigger Envelope protobuf? :thinking:

Hey :wave: let’s call it match data instead of match status, to avoid any confusion.

Setting aside xoxo – by default, match data will not be changed from the original format in which its sent from the client. If you send the match data as a string, it will be returned as a string and will not be converted internally. Same goes for binary.

Reading how the client js implementation works, it seems that the entire match status is a string in a bigger Envelope protobuf? :thinking:

Correct, if you are using the Text adapter for nakama-js client. Keep in mind that nakama-js supports both Text and Binary.

then protojson is serializing it as string and I could serialize them with the proto.Marhsall, to send binary, right?

And if I follow you, I could them use nakama-js and “teach” it my proto definition and get it parsed as a javascripty thing? :thinking:

Yes protojson is for JSON (string/text) and proto.Marshal is for binary.

And yes you can absolutely use protobuf and serialize the messages as text with our default adapter or binary with our protobuf adapter: @heroiclabs/nakama-js-protobuf NPM | npm.io