Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
96cfe746
Commit
96cfe746
authored
Apr 24, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed some warnings
parent
8d4cf5ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
src/json.hpp
src/json.hpp
+8
-8
src/json.hpp.re2c
src/json.hpp.re2c
+8
-8
No files found.
src/json.hpp
View file @
96cfe746
...
...
@@ -9522,7 +9522,7 @@ basic_json_parser_63:
basic_json
result
=
*
this
;
// wrapper for "add" operation; add value at ptr
const
auto
operation_add
=
[
&
result
](
json_pointer
&
ptr
,
basic_json
val
ue
)
const
auto
operation_add
=
[
&
result
](
json_pointer
&
ptr
,
basic_json
val
)
{
// get reference to parent of JSON pointer ptr
const
auto
last_path
=
ptr
.
pop_back
();
...
...
@@ -9531,19 +9531,19 @@ basic_json_parser_63:
if
(
parent
.
is_object
())
{
// use operator[] to add value
parent
[
last_path
]
=
val
ue
;
parent
[
last_path
]
=
val
;
}
else
if
(
parent
.
is_array
())
{
if
(
last_path
==
"-"
)
{
// special case: append to back
parent
.
push_back
(
val
ue
);
parent
.
push_back
(
val
);
}
else
{
// default case: insert add offset
parent
.
insert
(
parent
.
begin
()
+
std
::
stoi
(
last_path
),
val
ue
);
parent
.
insert
(
parent
.
begin
()
+
std
::
stoi
(
last_path
),
val
);
}
}
};
...
...
@@ -9579,7 +9579,7 @@ basic_json_parser_63:
// wrapper to get a value for an operation
const
auto
get_value
=
[
&
val
](
const
std
::
string
&
op
,
const
std
::
string
&
member
,
bool
string_type
=
false
)
->
basic_json
&
bool
string_type
)
->
basic_json
&
{
// find value
auto
it
=
val
.
m_value
.
object
->
find
(
member
);
...
...
@@ -9616,7 +9616,7 @@ basic_json_parser_63:
if
(
op
==
"add"
)
{
operation_add
(
ptr
,
get_value
(
"add"
,
"value"
));
operation_add
(
ptr
,
get_value
(
"add"
,
"value"
,
false
));
}
else
if
(
op
==
"remove"
)
{
...
...
@@ -9624,7 +9624,7 @@ basic_json_parser_63:
}
else
if
(
op
==
"replace"
)
{
result
.
at
(
ptr
)
=
get_value
(
"replace"
,
"value"
);
result
.
at
(
ptr
)
=
get_value
(
"replace"
,
"value"
,
false
);
}
else
if
(
op
==
"move"
)
{
...
...
@@ -9644,7 +9644,7 @@ basic_json_parser_63:
}
else
if
(
op
==
"test"
)
{
if
(
result
.
at
(
ptr
)
!=
get_value
(
"test"
,
"value"
))
if
(
result
.
at
(
ptr
)
!=
get_value
(
"test"
,
"value"
,
false
))
{
throw
std
::
domain_error
(
"unsuccessful: "
+
val
.
dump
());
}
...
...
src/json.hpp.re2c
View file @
96cfe746
...
...
@@ -8832,7 +8832,7 @@ class basic_json
basic_json result = *this;
// wrapper for "add" operation; add value at ptr
const auto operation_add = [&result](json_pointer & ptr, basic_json val
ue
)
const auto operation_add = [&result](json_pointer & ptr, basic_json val)
{
// get reference to parent of JSON pointer ptr
const auto last_path = ptr.pop_back();
...
...
@@ -8841,19 +8841,19 @@ class basic_json
if (parent.is_object())
{
// use operator[] to add value
parent[last_path] = val
ue
;
parent[last_path] = val;
}
else if (parent.is_array())
{
if (last_path == "-")
{
// special case: append to back
parent.push_back(val
ue
);
parent.push_back(val);
}
else
{
// default case: insert add offset
parent.insert(parent.begin() + std::stoi(last_path), val
ue
);
parent.insert(parent.begin() + std::stoi(last_path), val);
}
}
};
...
...
@@ -8889,7 +8889,7 @@ class basic_json
// wrapper to get a value for an operation
const auto get_value = [&val](const std::string & op,
const std::string & member,
bool string_type
= false
) -> basic_json&
bool string_type) -> basic_json&
{
// find value
auto it = val.m_value.object->find(member);
...
...
@@ -8926,7 +8926,7 @@ class basic_json
if (op == "add")
{
operation_add(ptr, get_value("add", "value"));
operation_add(ptr, get_value("add", "value"
, false
));
}
else if (op == "remove")
{
...
...
@@ -8934,7 +8934,7 @@ class basic_json
}
else if (op == "replace")
{
result.at(ptr) = get_value("replace", "value");
result.at(ptr) = get_value("replace", "value"
, false
);
}
else if (op == "move")
{
...
...
@@ -8954,7 +8954,7 @@ class basic_json
}
else if (op == "test")
{
if (result.at(ptr) != get_value("test", "value"))
if (result.at(ptr) != get_value("test", "value"
, false
))
{
throw std::domain_error("unsuccessful: " + val.dump());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment