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

[Request] Re-Use Buffer for serializeJson() #1569

Open
schlimmchen opened this issue Jan 22, 2025 · 0 comments
Open

[Request] Re-Use Buffer for serializeJson() #1569

schlimmchen opened this issue Jan 22, 2025 · 0 comments
Labels
acknowledged enhancement New feature or request

Comments

@schlimmchen
Copy link
Member

Is your feature request related to a problem? Please describe.

Currently, when using serializeJson() in the context of the Web API (to write the JSON into a websocket), we allocate a String, serialize the JSON into that String instance, and then call textAll(String) on the websocket. This creates a copy of the buffer inside AsyncWebsocket.

Describe the solution you'd like

Create an AsyncWebSocketSharedBuffer (std::shared_ptr<std::vector<uint8_t>>) rather than a String and have ArduinoJSON serialize the JSON into that buffer using a custom writer. That will merely create a copy of the std::shared_ptr, but not of the buffer itself.

Describe alternatives you've considered

No response

Additional context

No response

@schlimmchen schlimmchen added enhancement New feature or request acknowledged labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant