Closed linux-rm closed 1 year ago
But this is OK:
std::cout << message["messageChain"][0]["text"] << std::endl;
result:
"早上好\n距离中考还剩"
Can you compile with JSON_DIAGNOSTICS? See https://json.nlohmann.me/api/macros/json_diagnostics/
info:
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_2::detail::type_error'
what(): [json.exception.type_error.305] cannot use operator[] with a string argument with array
There should be more information? Did you enable diagnostics?
I found the problem, here:
code:
message["messageChain"]["target"] = 951234938;
json:
{
"target":0,// It is not in "messageChain"
/*......*/
}
Now, It is no problem.
Description
terminating with uncaught exception of type nlohmann::json_abi_v3_11_2::detail::type_error: [json.exception.type_error.305] cannot use operator[] with a string argument with array
code:
Reproduction steps
Minimal code example
Compiler and operating system
linux,g++,x86_64(fedora) and arm64(android)
Library version
3.11.2
Validation
develop
branch is used.