How can I turn a string of a json array into a json array? #1526
Labels
kind: question
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Hello!
I receive messages like these as a string:
[10, "1234", "Test"]
Now I want to turn this into a json object holding that array. It works when I pass the arguments by hand like this:
json j;
j = {10, "1234", "Test"};
std::cout << j[0] << j[1] << j[2]
But when I pass a string, everything except j[0] is null because the json object obviously treats the whole string as one object.
std::string json_string = "10, \"1234\", \"Test\"";
json j;
j = {json_string};
std::cout << j[0] << j[1] << j[2]
How can I solve this? Thanks in advance!
The text was updated successfully, but these errors were encountered: