Skip to content

How to serialize JSON to std::vector<uint8_t>? #2548

Answered by nlohmann
db4 asked this question in Q&A
Discussion options

You must be logged in to vote

This is currently not possible out of the box. You would need to serialize to a std::string and then create a vector out of that:

auto str = j.dump();
std::vector<std::uint8_t> data(str.begin(), str.end());

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@db4
Comment options

Answer selected by db4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants