-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Streaming binary representations #477
Comments
You mean a signature like static void to_cbor(const basic_json &j, std::ostream &o) for writing? |
Yup. It would help if you had a multi-GB JSON file. By creating a vector and then parsing, essentially 2 copies are held in memory until parsing is complete and the vector can be destroyed. |
Opened #623 as place to discuss the structure of the parsing functions. |
- You can now pass a reference to a vector to the to_cbor and to_msgpack functions. The output will be written (appended) to the vector. #476 - You can now pass an output stream with uint8_t character type to the to_cbor and to_msgpack functions. #477 - You can now read from uint8_t */size in the to_cbor and to_msgpack functions. An input adapter will be created from this pair, so you need to use braces. #478
Function static void to_cbor(const basic_json& j, detail::output_adapter<uint8_t> o)
{
binary_writer(o).write_cbor(j);
} now allows to write CBOR (and similarly, MessagePack) to the following types from which an
Note there is no function yet to write to |
Done. |
Currently the CBOR and MessagePack requires a vector of bytes for reading/writing. It would be beneficial to enable byte by byte consumption, like in standard file streams. This helps prevent allocating more memory than necessary (large JSON files).
Looking at the implementation this doesn't seem like it would be too difficult, some additional checking would be needed to make sure enough bytes are available.
The text was updated successfully, but these errors were encountered: