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
c0a8b45b
Commit
c0a8b45b
authored
Jan 09, 2021
by
Anthony VH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed template parameter and added some comments.
parent
1e825e4f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
22 deletions
+54
-22
adl_serializer.hpp
include/nlohmann/adl_serializer.hpp
+25
-11
from_json.hpp
include/nlohmann/detail/conversions/from_json.hpp
+2
-0
json.hpp
single_include/nlohmann/json.hpp
+27
-11
No files found.
include/nlohmann/adl_serializer.hpp
View file @
c0a8b45b
...
...
@@ -19,23 +19,37 @@ struct adl_serializer
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@note This function is chosen for value types which can be default constructed.
@param[in] j JSON value to read from
@param[in,out] val value to write to
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
,
U
&
val
)
noexcept
(
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
,
TargetType
&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
)))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
),
void
())
{
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
);
}
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
/*!
@brief convert a JSON value to any value type
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@note This function is chosen for value types which can not be default constructed.
@param[in] j JSON value to read from
@return copy of the JSON value, converted to @a ValueType
*/
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
)
noexcept
(
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
U
>
{})))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
U
>
{}))
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
TargetType
>
{})))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
TargetType
>
{}))
{
return
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
U
>
{});
return
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
TargetType
>
{});
}
/*!
...
...
@@ -47,12 +61,12 @@ struct adl_serializer
@param[in,out] j JSON value to write to
@param[in] val value to read from
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
static
auto
to_json
(
BasicJsonType
&
j
,
U
&&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
))))
->
decltype
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
)),
void
())
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
to_json
(
BasicJsonType
&
j
,
TargetType
&&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
))))
->
decltype
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
)),
void
())
{
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
));
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
));
}
};
}
// namespace nlohmann
include/nlohmann/detail/conversions/from_json.hpp
View file @
c0a8b45b
...
...
@@ -462,6 +462,8 @@ struct from_json_fn
return
from_json
(
j
,
val
);
}
// overload to pass calls to built-in from_json functions for non-default constructible STL
// types (e.g. std::array<X>, where X is not default constructible).
template
<
typename
BasicJsonType
,
typename
T
>
auto
operator
()(
const
BasicJsonType
&
j
,
detail
::
tag
<
T
>
t
)
const
noexcept
(
noexcept
(
from_json
(
j
,
t
)))
...
...
single_include/nlohmann/json.hpp
View file @
c0a8b45b
...
...
@@ -3959,6 +3959,8 @@ struct from_json_fn
return
from_json
(
j
,
val
);
}
// overload to pass calls to built-in from_json functions for non-default constructible STL
// types (e.g. std::array<X>, where X is not default constructible).
template
<
typename
BasicJsonType
,
typename
T
>
auto
operator
()(
const
BasicJsonType
&
j
,
detail
::
tag
<
T
>
t
)
const
noexcept
(
noexcept
(
from_json
(
j
,
t
)))
...
...
@@ -4553,23 +4555,37 @@ struct adl_serializer
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@note This function is chosen for value types which can be default constructed.
@param[in] j JSON value to read from
@param[in,out] val value to write to
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
,
U
&
val
)
noexcept
(
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
,
TargetType
&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
)))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
),
void
())
{
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
);
}
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
/*!
@brief convert a JSON value to any value type
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@note This function is chosen for value types which can not be default constructed.
@param[in] j JSON value to read from
@return copy of the JSON value, converted to @a ValueType
*/
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
)
noexcept
(
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
U
>
{})))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
U
>
{}))
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
TargetType
>
{})))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
TargetType
>
{}))
{
return
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
U
>
{});
return
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
detail
::
tag
<
TargetType
>
{});
}
/*!
...
...
@@ -4581,12 +4597,12 @@ struct adl_serializer
@param[in,out] j JSON value to write to
@param[in] val value to read from
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
static
auto
to_json
(
BasicJsonType
&
j
,
U
&&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
))))
->
decltype
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
)),
void
())
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
to_json
(
BasicJsonType
&
j
,
TargetType
&&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
))))
->
decltype
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
)),
void
())
{
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
));
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
));
}
};
}
// namespace nlohmann
...
...
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