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
a1828bbf
Unverified
Commit
a1828bbf
authored
Nov 01, 2019
by
Niels Lohmann
Committed by
GitHub
Nov 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1806 from cbegue/develop
Fix issue #1805
parents
f272ad53
794a3d41
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
include/nlohmann/detail/conversions/to_json.hpp
include/nlohmann/detail/conversions/to_json.hpp
+2
-2
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+2
-2
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+16
-0
No files found.
include/nlohmann/detail/conversions/to_json.hpp
View file @
a1828bbf
...
...
@@ -302,8 +302,8 @@ void to_json(BasicJsonType& j, const T(&arr)[N])
external_constructor
<
value_t
::
array
>::
construct
(
j
,
arr
);
}
template
<
typename
BasicJsonType
,
typename
...
Args
>
void
to_json
(
BasicJsonType
&
j
,
const
std
::
pair
<
Args
...
>&
p
)
template
<
typename
BasicJsonType
,
typename
T1
,
typename
T2
,
enable_if_t
<
std
::
is_constructible
<
BasicJsonType
,
T1
>
::
value
&&
std
::
is_constructible
<
BasicJsonType
,
T2
>
::
value
,
int
>
=
0
>
void
to_json
(
BasicJsonType
&
j
,
const
std
::
pair
<
T1
,
T2
>&
p
)
{
j
=
{
p
.
first
,
p
.
second
};
}
...
...
single_include/nlohmann/json.hpp
View file @
a1828bbf
...
...
@@ -3733,8 +3733,8 @@ void to_json(BasicJsonType& j, const T(&arr)[N])
external_constructor
<
value_t
::
array
>::
construct
(
j
,
arr
);
}
template
<
typename
BasicJsonType
,
typename
...
Args
>
void
to_json
(
BasicJsonType
&
j
,
const
std
::
pair
<
Args
...
>&
p
)
template
<
typename
BasicJsonType
,
typename
T1
,
typename
T2
,
enable_if_t
<
std
::
is_constructible
<
BasicJsonType
,
T1
>
::
value
&&
std
::
is_constructible
<
BasicJsonType
,
T2
>
::
value
,
int
>
=
0
>
void
to_json
(
BasicJsonType
&
j
,
const
std
::
pair
<
T1
,
T2
>&
p
)
{
j
=
{
p
.
first
,
p
.
second
};
}
...
...
test/src/unit-regression.cpp
View file @
a1828bbf
...
...
@@ -159,6 +159,16 @@ bool operator==(Data const& lhs, Data const& rhs)
using
float_json
=
nlohmann
::
basic_json
<
std
::
map
,
std
::
vector
,
std
::
string
,
bool
,
std
::
int64_t
,
std
::
uint64_t
,
float
>
;
/////////////////////////////////////////////////////////////////////
// for #1805
/////////////////////////////////////////////////////////////////////
struct
NotSerializableData
{
int
mydata
;
float
myfloat
;
};
TEST_CASE
(
"regression tests"
)
{
...
...
@@ -1820,6 +1830,12 @@ TEST_CASE("regression tests")
CHECK
(
j
.
contains
(
jptr1
));
CHECK
(
j
.
contains
(
jptr2
));
}
SECTION
(
"issue #1805 - A pair<T1, T2> is json constructible only if T1 and T2 are json constructible"
)
{
static_assert
(
!
std
::
is_constructible
<
json
,
std
::
pair
<
std
::
string
,
NotSerializableData
>>::
value
,
""
);
static_assert
(
!
std
::
is_constructible
<
json
,
std
::
pair
<
NotSerializableData
,
std
::
string
>>::
value
,
""
);
static_assert
(
std
::
is_constructible
<
json
,
std
::
pair
<
int
,
std
::
string
>>::
value
,
""
);
}
}
#if not defined(JSON_NOEXCEPTION)
...
...
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