You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_3::detail::type_error'
what(): [json.exception.type_error.305] cannot use operator[] with a string argument with array
I did some tests and apparently the inner json (ie. {"error":"error_str"}) is treated as an array.
My question is how can it possibly be treated that way? What am I doing wrong ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have this simple json object:
That is to be deserialized as follow:
{"key": {"error":"error_str"}}
When I try to push this json into a std::vector:
std::vector artifacts;
artifacts.push_back(obj["key"]);
I get the following exception:
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_3::detail::type_error'
what(): [json.exception.type_error.305] cannot use operator[] with a string argument with array
I did some tests and apparently the inner json (ie. {"error":"error_str"}) is treated as an array.
My question is how can it possibly be treated that way? What am I doing wrong ?
Beta Was this translation helpful? Give feedback.
All reactions