# Is protojson converted to binary inside the runtime?

**URL:** <https://forum.heroiclabs.com/t/is-protojson-converted-to-binary-inside-the-runtime/4274>\
**Category:** Runtime Framework\
**Tags:** golang\
**Created:** [August 28, 2023, 4:18pm UTC](https://forum.heroiclabs.com/t/is-protojson-converted-to-binary-inside-the-runtime/4274 "2023-08-28T16:18:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elementalcode](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/elementalcode/32/1697_2.png) [@elementalcode](https://forum.heroiclabs.com/u/elementalcode)\
**Post date:** [August 28, 2023, 4:18pm UTC](https://forum.heroiclabs.com/t/is-protojson-converted-to-binary-inside-the-runtime/4274/1 "2023-08-28T16:18:21Z")

</div>

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

> <https://github.com/heroiclabs/nakama-project-template/blob/master/match_handler.go#L62>

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 😅

* * *

edit:

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

---

<div class="post-metadata">

**Author:** ![lugehorsam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/lugehorsam/32/314_2.png) [@lugehorsam](https://forum.heroiclabs.com/u/lugehorsam)\
**Post date:** [August 28, 2023, 8:16pm UTC](https://forum.heroiclabs.com/t/is-protojson-converted-to-binary-inside-the-runtime/4274/2 "2023-08-28T20:16:32Z")

</div>

Hey 👋 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? 🤔

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

---

<div class="post-metadata">

**Author:** ![elementalcode](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/elementalcode/32/1697_2.png) [@elementalcode](https://forum.heroiclabs.com/u/elementalcode)\
**Post date:** [August 28, 2023, 10:30pm UTC](https://forum.heroiclabs.com/t/is-protojson-converted-to-binary-inside-the-runtime/4274/3 "2023-08-28T22:30:45Z")

</div>

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? 🤔

---

<div class="post-metadata">

**Author:** ![lugehorsam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/lugehorsam/32/314_2.png) [@lugehorsam](https://forum.heroiclabs.com/u/lugehorsam)\
**Post date:** [August 28, 2023, 10:38pm UTC](https://forum.heroiclabs.com/t/is-protojson-converted-to-binary-inside-the-runtime/4274/4 "2023-08-28T22:38:29Z")

</div>

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](https://npm.io/package/@heroiclabs/nakama-js-protobuf)
