File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
include/jsoncons_ext/jsonpointer Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -799,6 +799,10 @@ namespace jsonpointer {
799
799
bool create_if_missing,
800
800
std::error_code& ec)
801
801
{
802
+ if (location.empty ())
803
+ {
804
+ return ;
805
+ }
802
806
Json* current = std::addressof (root);
803
807
804
808
std::basic_string<typename Json::char_type> buffer;
@@ -940,6 +944,7 @@ namespace jsonpointer {
940
944
{
941
945
if (location.empty ())
942
946
{
947
+ ec = jsonpointer_errc::expected_location;
943
948
return ;
944
949
}
945
950
@@ -1047,6 +1052,11 @@ namespace jsonpointer {
1047
1052
bool create_if_missing,
1048
1053
std::error_code& ec)
1049
1054
{
1055
+ if (location.empty ())
1056
+ {
1057
+ root = std::forward<T>(value);
1058
+ return ;
1059
+ }
1050
1060
Json* current = std::addressof (root);
1051
1061
1052
1062
std::basic_string<typename Json::char_type> buffer;
Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ enum class jsonpointer_errc
55
55
unexpected_end_of_input,
56
56
argument_to_unflatten_invalid,
57
57
invalid_flattened_key,
58
- invalid_uri_escaped_data
58
+ invalid_uri_escaped_data,
59
+ expected_location
59
60
};
60
61
61
62
class jsonpointer_error_category_impl
@@ -92,6 +93,8 @@ class jsonpointer_error_category_impl
92
93
return " Argument to unflatten must be an object" ;
93
94
case jsonpointer_errc::invalid_flattened_key:
94
95
return " Flattened key is invalid" ;
96
+ case jsonpointer_errc::expected_location:
97
+ return " Expected location" ;
95
98
default :
96
99
return " Unknown jsonpointer error" ;
97
100
}
You can’t perform that action at this time.
0 commit comments