3 ms·
You can parse and encode JSON without dynamic memory allocation. You can encode base64 without dynamic memory allocation, and you can even decode it in-place. Y
by boomlinde 2y ago
You can parse and encode JSON without dynamic memory allocation. You can encode base64 without dynamic memory allocation, and you can even decode it in-place. You just need to know the appropriate buffer sizes for a valid payload. For base64 this is a trivial function of the input size. For a streaming decoder you don't even need more than a fixed few bytes of state.
I am not arguing that either of these are appropriate for your application, particularly not base64, which doesn't address the basic problem of representing structured data, but it isn't true that they require dynamic allocation, which is good to keep in mind if you ever find yourself in need of these encoding schemes in a resource constrained system.