例如,使用 nlohmann::json,我可以做到
map<string, vector<int>> m = { {"a", {1, 2}}, {"b", {2, 3}} };
json j = m;
但我做不到
m = j;
有什么方法可以使用 nlohmann::json 将 json 对象转换为地图?
原文由 user1899020 发布,翻译遵循 CC BY-SA 4.0 许可协议
例如,使用 nlohmann::json,我可以做到
map<string, vector<int>> m = { {"a", {1, 2}}, {"b", {2, 3}} };
json j = m;
但我做不到
m = j;
有什么方法可以使用 nlohmann::json 将 json 对象转换为地图?
原文由 user1899020 发布,翻译遵循 CC BY-SA 4.0 许可协议
3 回答1.4k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
1 回答760 阅读✓ 已解决
4 回答931 阅读
1 回答999 阅读
1 回答1k 阅读
1 回答788 阅读
nlomann::json 可以使用
get<typename BasicJsonType>() const
将 Json 对象转换为大多数标准 STL 容器例子: