Decode json string to a struct
Posted: Wed Nov 18, 2020 9:59 am
I have a struct with a few string data members. Encoding this struct to a json string works perfectly fine with jsonEncode().
But when I try to convert this json string back to the struct using jsonDecode I get a warning message that the returned data type does not match my struct data type.
WARNING, 28/ctrl, mapping, Übergebener Datentyp entspricht nicht dem benötigten Typ 'BeccInfoWindowEntry',
I think the problem is that the jsonDecode() returns just a mapping and this, of course, can not be assigned to the struct.
Is there a way to tell jsonDecode() it should decode into and return the struct?
But when I try to convert this json string back to the struct using jsonDecode I get a warning message that the returned data type does not match my struct data type.
WARNING, 28/ctrl, mapping, Übergebener Datentyp entspricht nicht dem benötigten Typ 'BeccInfoWindowEntry',
I think the problem is that the jsonDecode() returns just a mapping and this, of course, can not be assigned to the struct.
Is there a way to tell jsonDecode() it should decode into and return the struct?