mirror of
https://github.com/nlohmann/json.git
synced 2025-07-13 20:21:48 +03:00
replace and copy
This commit is contained in:
@ -8835,6 +8835,7 @@ class basic_json
|
||||
const auto it_op = val.m_value.object->find("op");
|
||||
const auto it_path = val.m_value.object->find("path");
|
||||
const auto it_value = val.m_value.object->find("value");
|
||||
const auto it_from = val.m_value.object->find("from");
|
||||
|
||||
if (it_op == val.m_value.object->end() or not it_op->second.is_string())
|
||||
{
|
||||
@ -8868,12 +8869,30 @@ class basic_json
|
||||
{
|
||||
throw std::domain_error("'replace' operation must have member 'value'");
|
||||
}
|
||||
|
||||
result.at(ptr) = it_value->second;
|
||||
}
|
||||
else if (op == "move")
|
||||
{
|
||||
if (it_from == val.m_value.object->end())
|
||||
{
|
||||
throw std::domain_error("'move' operation must have member 'from'");
|
||||
}
|
||||
|
||||
const std::string from_path = it_from->second;
|
||||
const json_pointer from_ptr(from_path);
|
||||
}
|
||||
else if (op == "copy")
|
||||
{
|
||||
if (it_from == val.m_value.object->end())
|
||||
{
|
||||
throw std::domain_error("'copy' operation must have member 'from'");
|
||||
}
|
||||
|
||||
const std::string from_path = it_from->second;
|
||||
const json_pointer from_ptr(from_path);
|
||||
|
||||
result[ptr] = result.at(from_ptr);
|
||||
}
|
||||
else if (op == "test")
|
||||
{
|
||||
|
Reference in New Issue
Block a user