-
When I replace a string KV with json object in a array, json report an error: My codes likes below: json_t obj = json_t::parse(str1);
json_t& items = obj["items"];
for (auto& item : items) {
std::string str2 = handle_data(item["data"].get<std::string>());
action["data"] = json_t::parse(str2);
} orgin json string is like below: {
"items": [
{
"id": "123",
"data":"1f75620e7e"
},
{
"id": "456",
"data":"afd3e1d8b3"
}
]
} I want to replace each item's data field with a new json object, the result will likes below: {
"items": [
{
"id": "123",
"data":{"k1":"v1", "k2":"v2"}
},
{
"id": "456",
"data":{"k1":"v3", "k2":"v4"}
},
]
} |
Beta Was this translation helpful? Give feedback.
Answered by
gzliudan
Aug 24, 2020
Replies: 1 comment
-
The problem is resolved, it's my log code raised exception after change type from string to object: LogInfo("new data={}", action.at("data").get<std::string>()); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gzliudan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is resolved, it's my log code raised exception after change type from string to object: