'uint16_t array to string and back c++

I have a uint16_t array and I want to be able to convert it to a string and convert it back. The goal is to save the array with this library and load it back into a variable. What would be the best approach?

I tried to read the json key to the variable

uint16_t *program;
program = json["script"];

but it gives me this error:

no suitable conversion function from "nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer, std::vector<uint8_t, std::allocator<uint8_t>>>" to "uint16_t *" exists

That's why I thought that maybe I should convert it to another datatype with available conversion first.

Solved:

I used vector<uint16_t> instead of an uint16_t array, which had available conversion in the library.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source