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
e3e9ccfc
Unverified
Commit
e3e9ccfc
authored
Jul 08, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚑
fix regression from #2181
parent
d019ddfc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
18 deletions
+27
-18
include/nlohmann/json.hpp
include/nlohmann/json.hpp
+6
-6
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+6
-6
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+9
-0
test/src/unit-udt_macro.cpp
test/src/unit-udt_macro.cpp
+6
-6
No files found.
include/nlohmann/json.hpp
View file @
e3e9ccfc
...
...
@@ -3785,7 +3785,7 @@ class basic_json
template
<
class
ValueType
,
typename
std
::
enable_if
<
std
::
is_convertible
<
basic_json_t
,
ValueType
>
::
value
and
not
std
::
is_same
<
value_t
,
ValueType
>::
value
,
int
>::
type
=
0
>
ValueType
value
(
const
typename
object_t
::
key_type
&
key
,
ValueType
&
&
default_value
)
const
ValueType
value
(
const
typename
object_t
::
key_type
&
key
,
const
ValueType
&
default_value
)
const
{
// at only works for objects
if
(
JSON_HEDLEY_LIKELY
(
is_object
()))
...
...
@@ -3797,7 +3797,7 @@ class basic_json
return
*
it
;
}
return
std
::
move
(
default_value
)
;
return
default_value
;
}
JSON_THROW
(
type_error
::
create
(
306
,
"cannot use value() with "
+
std
::
string
(
type_name
())));
...
...
@@ -3809,7 +3809,7 @@ class basic_json
*/
string_t
value
(
const
typename
object_t
::
key_type
&
key
,
const
char
*
default_value
)
const
{
return
value
(
key
,
st
d
::
move
(
string_t
(
default_value
)
));
return
value
(
key
,
st
ring_t
(
default_value
));
}
/*!
...
...
@@ -3857,7 +3857,7 @@ class basic_json
*/
template
<
class
ValueType
,
typename
std
::
enable_if
<
std
::
is_convertible
<
basic_json_t
,
ValueType
>
::
value
,
int
>::
type
=
0
>
ValueType
value
(
const
json_pointer
&
ptr
,
ValueType
&
&
default_value
)
const
ValueType
value
(
const
json_pointer
&
ptr
,
const
ValueType
&
default_value
)
const
{
// at only works for objects
if
(
JSON_HEDLEY_LIKELY
(
is_object
()))
...
...
@@ -3869,7 +3869,7 @@ class basic_json
}
JSON_INTERNAL_CATCH
(
out_of_range
&
)
{
return
std
::
move
(
default_value
)
;
return
default_value
;
}
}
...
...
@@ -3883,7 +3883,7 @@ class basic_json
JSON_HEDLEY_NON_NULL
(
3
)
string_t
value
(
const
json_pointer
&
ptr
,
const
char
*
default_value
)
const
{
return
value
(
ptr
,
st
d
::
move
(
string_t
(
default_value
)
));
return
value
(
ptr
,
st
ring_t
(
default_value
));
}
/*!
...
...
single_include/nlohmann/json.hpp
View file @
e3e9ccfc
...
...
@@ -19715,7 +19715,7 @@ class basic_json
template
<
class
ValueType
,
typename
std
::
enable_if
<
std
::
is_convertible
<
basic_json_t
,
ValueType
>
::
value
and
not
std
::
is_same
<
value_t
,
ValueType
>::
value
,
int
>::
type
=
0
>
ValueType
value
(
const
typename
object_t
::
key_type
&
key
,
ValueType
&
&
default_value
)
const
ValueType
value
(
const
typename
object_t
::
key_type
&
key
,
const
ValueType
&
default_value
)
const
{
// at only works for objects
if
(
JSON_HEDLEY_LIKELY
(
is_object
()))
...
...
@@ -19727,7 +19727,7 @@ class basic_json
return
*
it
;
}
return
std
::
move
(
default_value
)
;
return
default_value
;
}
JSON_THROW
(
type_error
::
create
(
306
,
"cannot use value() with "
+
std
::
string
(
type_name
())));
...
...
@@ -19739,7 +19739,7 @@ class basic_json
*/
string_t
value
(
const
typename
object_t
::
key_type
&
key
,
const
char
*
default_value
)
const
{
return
value
(
key
,
st
d
::
move
(
string_t
(
default_value
)
));
return
value
(
key
,
st
ring_t
(
default_value
));
}
/*!
...
...
@@ -19787,7 +19787,7 @@ class basic_json
*/
template
<
class
ValueType
,
typename
std
::
enable_if
<
std
::
is_convertible
<
basic_json_t
,
ValueType
>
::
value
,
int
>::
type
=
0
>
ValueType
value
(
const
json_pointer
&
ptr
,
ValueType
&
&
default_value
)
const
ValueType
value
(
const
json_pointer
&
ptr
,
const
ValueType
&
default_value
)
const
{
// at only works for objects
if
(
JSON_HEDLEY_LIKELY
(
is_object
()))
...
...
@@ -19799,7 +19799,7 @@ class basic_json
}
JSON_INTERNAL_CATCH
(
out_of_range
&
)
{
return
std
::
move
(
default_value
)
;
return
default_value
;
}
}
...
...
@@ -19813,7 +19813,7 @@ class basic_json
JSON_HEDLEY_NON_NULL
(
3
)
string_t
value
(
const
json_pointer
&
ptr
,
const
char
*
default_value
)
const
{
return
value
(
ptr
,
st
d
::
move
(
string_t
(
default_value
)
));
return
value
(
ptr
,
st
ring_t
(
default_value
));
}
/*!
...
...
test/src/unit-regression.cpp
View file @
e3e9ccfc
...
...
@@ -1945,6 +1945,15 @@ TEST_CASE("regression tests")
)
);
}
SECTION
(
"PR #2181 - regression bug with lvalue"
)
{
// see https://github.com/nlohmann/json/pull/2181#issuecomment-653326060
json
j
{{
"x"
,
"test"
}};
std
::
string
defval
=
"default value"
;
auto
val
=
j
.
value
(
"x"
,
defval
);
auto
val2
=
j
.
value
(
"y"
,
defval
);
}
}
#if not defined(JSON_NOEXCEPTION)
...
...
test/src/unit-udt_macro.cpp
View file @
e3e9ccfc
...
...
@@ -60,9 +60,9 @@ class person_with_private_data
class
person_without_private_data_1
{
public:
std
::
string
name
=
""
;
int
age
=
0
;
json
metadata
=
nullptr
;
std
::
string
name
=
""
;
int
age
=
0
;
json
metadata
=
nullptr
;
bool
operator
==
(
const
person_without_private_data_1
&
rhs
)
const
{
...
...
@@ -82,9 +82,9 @@ class person_without_private_data_1
class
person_without_private_data_2
{
public:
std
::
string
name
=
""
;
int
age
=
0
;
json
metadata
=
nullptr
;
std
::
string
name
=
""
;
int
age
=
0
;
json
metadata
=
nullptr
;
bool
operator
==
(
const
person_without_private_data_2
&
rhs
)
const
{
...
...
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