Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow JSON stringified buffers to be converted to Buffer when serializing #124

Merged
merged 2 commits into from
May 20, 2021

Conversation

extremeheat
Copy link
Contributor

Needed for PrismarineJS/bedrock-protocol#83, allows serializing previously JSON.stringified packets.

Allows JSON stringified buffers to be converted to Buffer when serializing
@extremeheat extremeheat changed the title Allows JSON stringified buffers to be converted to Buffer when serializing Allow JSON stringified buffers to be converted to Buffer when serializing May 8, 2021
@KaffinPX
Copy link

KaffinPX commented May 8, 2021

LGTM

@rom1504
Copy link
Member

rom1504 commented May 8, 2021

Why can't you convert to buffer in the user code ?

@extremeheat
Copy link
Contributor Author

extremeheat commented May 8, 2021

In the tests,

  • the packets are serialized to JSON after parsing
  • written to disk
  • read from disk, JSON.parse'd
  • piped back to createPacketBuffer without any changes

It's possible to convert to buffer, but that would mean recursively walking through the objects then creating Buffer instances out of them. So there would have to be an intermediate parsing step before, with knowledge of the schema.

@rom1504
Copy link
Member

rom1504 commented May 8, 2021

Ok, can you make the same change in the interpreter ?

@extremeheat
Copy link
Contributor Author

done

@rom1504 rom1504 merged commit 4431eef into ProtoDef-io:master May 20, 2021
@extremeheat extremeheat deleted the patch-1 branch August 10, 2021 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants