Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
268600e6
Unverified
Commit
268600e6
authored
Mar 29, 2021
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
👌
apply review comments
parent
47c7e2cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
8 deletions
+38
-8
json.hpp
include/nlohmann/json.hpp
+19
-4
json.hpp
single_include/nlohmann/json.hpp
+19
-4
No files found.
include/nlohmann/json.hpp
View file @
268600e6
...
...
@@ -3725,12 +3725,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
// operator[] only works for objects
if
(
JSON_HEDLEY_LIKELY
(
is_object
()))
{
if
(
auto
it
=
m_value
.
object
->
find
(
key
);
it
!=
m_value
.
object
->
end
())
auto
it
=
m_value
.
object
->
find
(
key
);
if
(
it
!=
m_value
.
object
->
end
())
{
return
it
->
second
;
}
return
set_parent
(
m_value
.
object
->
operator
[](
json
::
object_t
::
key_type
(
key
)));
auto
result
=
m_value
.
object
->
emplace
(
key
,
nullptr
);
return
set_parent
(
result
.
first
->
second
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with a string argument with "
+
std
::
string
(
type_name
()),
*
this
));
...
...
@@ -4421,9 +4423,22 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
#if defined(JSON_HAS_CPP_17)
size_type
erase
(
std
::
string_view
key
)
size_type
erase
(
const
std
::
string_view
&
key
)
{
return
erase
(
typename
object_t
::
key_type
(
key
.
data
(),
key
.
size
()));
// this erase only works for objects
if
(
JSON_HEDLEY_UNLIKELY
(
!
is_object
()))
{
JSON_THROW
(
type_error
::
create
(
307
,
"cannot use erase() with "
+
std
::
string
(
type_name
()),
*
this
));
}
const
auto
it
=
m_value
.
object
->
find
(
key
);
if
(
it
!=
m_value
.
object
->
end
())
{
m_value
.
object
->
erase
(
it
);
return
1
;
}
return
0
;
}
#endif
...
...
single_include/nlohmann/json.hpp
View file @
268600e6
...
...
@@ -20614,12 +20614,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
// operator[] only works for objects
if
(
JSON_HEDLEY_LIKELY
(
is_object
()))
{
if
(
auto
it
=
m_value
.
object
->
find
(
key
);
it
!=
m_value
.
object
->
end
())
auto
it
=
m_value
.
object
->
find
(
key
);
if
(
it
!=
m_value
.
object
->
end
())
{
return
it
->
second
;
}
return
set_parent
(
m_value
.
object
->
operator
[](
json
::
object_t
::
key_type
(
key
)));
auto
result
=
m_value
.
object
->
emplace
(
key
,
nullptr
);
return
set_parent
(
result
.
first
->
second
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with a string argument with "
+
std
::
string
(
type_name
()),
*
this
));
...
...
@@ -21310,9 +21312,22 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
#if defined(JSON_HAS_CPP_17)
size_type
erase
(
std
::
string_view
key
)
size_type
erase
(
const
std
::
string_view
&
key
)
{
return
erase
(
typename
object_t
::
key_type
(
key
.
data
(),
key
.
size
()));
// this erase only works for objects
if
(
JSON_HEDLEY_UNLIKELY
(
!
is_object
()))
{
JSON_THROW
(
type_error
::
create
(
307
,
"cannot use erase() with "
+
std
::
string
(
type_name
()),
*
this
));
}
const
auto
it
=
m_value
.
object
->
find
(
key
);
if
(
it
!=
m_value
.
object
->
end
())
{
m_value
.
object
->
erase
(
it
);
return
1
;
}
return
0
;
}
#endif
...
...
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