-
I'm trying to parse a JSON array with the following code:
And I'm getting the following error and warning:
But I don't know why if I'm doing exactly as I'm doing on another program. The only difference is that I'm using a struct in the other program that works instead of a class ( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You need to define the namespace wbid {
void from_json(const nlohmann::json& j,MultiIO &multiIO)
{
wbid::MultiIOColor color;
j.at("color").get_to(color);
multiIO.setColor(color);
wbid::MultiIOType type;
j.at("type").get_to(type);
multiIO.setType(type);
uint16_t value;
j.at("color").get_to(value);
multiIO.setValue(value);
}
} Also make sure you have conversion functions for all the other types such as |
Beta Was this translation helpful? Give feedback.
You need to define the
from_json
function in the namespace of the respective type. So please try:Also make sure you have conversion functions for all the other types such as
wbid::MultiIOColor
orwbid::MultiIOType
.