Error: use of undeclared identifier 'key'
#include <nlohmann/json.hpp>
using json = nlohmann::json;
// 假设我们有两个JSON对象
json object1 = R"({"name": "John", "age": 30})"_json;
json object2 = R"({"address": "123 Main St", "phone": "555-1234"})"_json;
// 合并两个对象
for (auto& [key, value] : object2.items()) {
object1[key] = value; // 将object2的所有键值对添加到object1中
}
// 现在,object1包含了来自object2的数据
// object1的内容是 {"name": "John", "age": 30, "address": "123 Main St", "phone": "555-1234"}