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
aa2679a8
Commit
aa2679a8
authored
Dec 15, 2016
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests, avoid instantiating JSONSerializer when it will not be used
parent
d5ee5830
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
+17
-16
json.hpp
src/json.hpp
+10
-9
unit-udt.cpp
test/src/unit-udt.cpp
+7
-7
No files found.
src/json.hpp
View file @
aa2679a8
...
...
@@ -1614,13 +1614,14 @@ class basic_json
template
<
typename
T
,
enable_if_t
<
not
std
::
is_base_of
<
std
::
istream
,
uncvref_t
<
T
>>::
value
and
not
detail
::
is_compatible_basic_json_type
<
uncvref_t
<
T
>
,
basic_json_t
>::
value
and
not
detail
::
is_basic_json_nested_class
<
uncvref_t
<
T
>
,
basic_json_t
,
primitive_iterator_t
>::
value
and
not
std
::
is_same
<
uncvref_t
<
T
>
,
typename
basic_json_t
::
array_t
::
iterator
>::
value
and
not
std
::
is_same
<
uncvref_t
<
T
>
,
typename
basic_json_t
::
object_t
::
iterator
>::
value
and
detail
::
conjunction
<
detail
::
negation
<
detail
::
is_compatible_basic_json_type
<
uncvref_t
<
T
>
,
basic_json_t
>>
,
detail
::
has_to_json
<
JSONSerializer
,
basic_json
,
uncvref_t
<
T
>>::
value
,
uncvref_t
<
T
>>
>
::
value
,
int
>
=
0
>
basic_json
(
T
&&
val
)
{
...
...
@@ -3311,10 +3312,10 @@ class basic_json
template
<
typename
T
,
enable_if_t
<
not
detail
::
is_compatible_basic_json_type
<
uncvref_t
<
T
>
,
basic_json_t
>
::
value
and
enable_if_t
<
detail
::
conjunction
<
detail
::
negation
<
detail
::
is_compatible_basic_json_type
<
uncvref_t
<
T
>
,
basic_json_t
>
>
,
detail
::
has_from_json
<
JSONSerializer
,
basic_json_t
,
uncvref_t
<
T
>>::
value
,
uncvref_t
<
T
>>
>
::
value
,
int
>
=
0
>
auto
get
()
const
->
uncvref_t
<
T
>
{
...
...
@@ -3331,10 +3332,10 @@ class basic_json
// This overload is chosen for non-default constructible user-defined-types
template
<
typename
T
,
enable_if_t
<
not
detail
::
is_compatible_basic_json_type
<
T
,
basic_json_t
>::
value
and
enable_if_t
<
detail
::
conjunction
<
detail
::
negation
<
detail
::
is_compatible_basic_json_type
<
uncvref_t
<
T
>
,
basic_json_t
>>
,
detail
::
has_non_default_from_json
<
JSONSerializer
,
basic_json_t
,
T
>::
value
,
uncvref_t
<
T
>>
>::
value
,
short
>
=
0
>
T
get
()
const
{
...
...
test/src/unit-udt.cpp
View file @
aa2679a8
...
...
@@ -27,6 +27,7 @@ SOFTWARE.
*/
#include <array>
#include <map>
#include <string>
#include <memory>
#include "catch.hpp"
...
...
@@ -173,19 +174,19 @@ namespace udt
template
<
typename
Json
>
void
from_json
(
Json
const
&
j
,
age
&
a
)
{
a
.
m_val
=
j
.
get
<
int
>
();
a
.
m_val
=
j
.
template
get
<
int
>
();
}
template
<
typename
Json
>
void
from_json
(
Json
const
&
j
,
name
&
n
)
{
n
.
m_val
=
j
.
get
<
std
::
string
>
();
n
.
m_val
=
j
.
template
get
<
std
::
string
>
();
}
template
<
typename
Json
>
void
from_json
(
Json
const
&
j
,
country
&
c
)
{
const
auto
str
=
j
.
get
<
std
::
string
>
();
const
auto
str
=
j
.
template
get
<
std
::
string
>
();
static
const
std
::
map
<
std
::
string
,
country
>
m
=
{
{
u8"中华人民共和国"
,
country
::
china
},
{
"France"
,
country
::
france
},
...
...
@@ -199,9 +200,9 @@ namespace udt
template
<
typename
Json
>
void
from_json
(
Json
const
&
j
,
person
&
p
)
{
p
.
m_age
=
j
[
"age"
].
get
<
age
>
();
p
.
m_name
=
j
[
"name"
].
get
<
name
>
();
p
.
m_country
=
j
[
"country"
].
get
<
country
>
();
p
.
m_age
=
j
[
"age"
].
template
get
<
age
>
();
p
.
m_name
=
j
[
"name"
].
template
get
<
name
>
();
p
.
m_country
=
j
[
"country"
].
template
get
<
country
>
();
}
void
from_json
(
nlohmann
::
json
const
&
j
,
address
&
a
)
...
...
@@ -325,7 +326,6 @@ struct adl_serializer<udt::legacy_type>
TEST_CASE
(
"adl_serializer specialization"
,
"[udt]"
)
{
SECTION
(
"partial specialization"
)
{
SECTION
(
"to_json"
)
...
...
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