Skip to content

Conversation

@metatablecat
Copy link
Contributor

Changes

Adds a previously undocumented note about buffer being supported in JSONEncode, which returns a compressed and encoded variant of the buffer.

I'm unsure if Base64 in this addition is formatted correctly to style.

Checks

By submitting your pull request for review, you agree to the following:

  • This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses.
  • I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses.
  • To the best of my knowledge, all proposed changes are accurate.

@metatablecat metatablecat requested a review from a team as a code owner August 19, 2025 11:52
@github-actions github-actions bot added the engine reference Changes the Engine API Reference documentation label Aug 19, 2025
JSON. This may cause problems if you want to use the outputted JSON
elsewhere.
This method can also take a `Datatype.buffer`, which will compress and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean a buffer created through the buffer library, such as through buffer.create()?
https://create.roblox.com/docs/en-us/reference/engine/libraries/buffer#create

@aetter
Copy link
Contributor

aetter commented Aug 29, 2025

Hey @metatablecat, this is super interesting, thanks for bringing it to our attention. A couple things:

  • We don't take PRs on the reference documentation anymore, but I'll port a version of this over to our internal source. It typically takes a couple weeks to get reviewed and incorporated into a release.
  • My extremely quick testing indicates that JSONEncode() doesn't always compress the buffer (fromstring seems to come out as base64 rather than zbase64), so I'll work with engineering to see if there's a bit more complexity to note about how these get handled.

@aetter aetter closed this Aug 29, 2025
@metatablecat
Copy link
Contributor Author

Hey @metatablecat, this is super interesting, thanks for bringing it to our attention. A couple things:

* We don't take PRs on the reference documentation anymore, but I'll port a version of this over to our internal source. It typically takes a couple weeks to get reviewed and incorporated into a release.

* My extremely quick testing indicates that JSONEncode() doesn't always compress the buffer (`fromstring` seems to come out as `base64` rather than `zbase64`), so I'll work with engineering to see if there's a bit more complexity to note about how these get handled.

I know this was closed a week ago but I wanted to give this a little more investigating myself, it appears it only generates zbase64 if the stream could actually be compressed, I don’t know what specifically zstd does to consider if a stream is "compressible" but it is what it is.

@aetter
Copy link
Contributor

aetter commented Sep 8, 2025

Hey @metatablecat, this is super interesting, thanks for bringing it to our attention. A couple things:

* We don't take PRs on the reference documentation anymore, but I'll port a version of this over to our internal source. It typically takes a couple weeks to get reviewed and incorporated into a release.

* My extremely quick testing indicates that JSONEncode() doesn't always compress the buffer (`fromstring` seems to come out as `base64` rather than `zbase64`), so I'll work with engineering to see if there's a bit more complexity to note about how these get handled.

I know this was closed a week ago but I wanted to give this a little more investigating myself, it appears it only generates zbase64 if the stream could actually be compressed, I don’t know what specifically zstd does to consider if a stream is "compressible" but it is what it is.

100%. I believe I went with "it encodes to base64 (and often compresses)" since the cases aren't obvious and we handle it with JSONDecode regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine reference Changes the Engine API Reference documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants