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
c0a8b45b
Commit
c0a8b45b
authored
4 years ago
by
Anthony VH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed template parameter and added some comments.
parent
1e825e4f
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
22 deletions
+54
-22
include/nlohmann/adl_serializer.hpp
include/nlohmann/adl_serializer.hpp
+25
-11
include/nlohmann/detail/conversions/from_json.hpp
include/nlohmann/detail/conversions/from_json.hpp
+2
-0
single_include/nlohmann/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
...
@@ -19,23 +19,37 @@ struct adl_serializer
This function is usually called by the `get()` function of the
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@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] j JSON value to read from
@param[in,out] val value to write to
@param[in,out] val value to write to
*/
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
,
U
&
val
)
noexcept
(
static
auto
from_json
(
BasicJsonType
&&
j
,
TargetType
&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
)))
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
)))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
),
void
())
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
),
void
())
{
{
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
);
::
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
(
static
auto
from_json
(
BasicJsonType
&&
j
)
noexcept
(
noexcept
(
::
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
<
U
>
{}))
->
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
...
@@ -47,12 +61,12 @@ struct adl_serializer
@param[in,out] j JSON value to write to
@param[in,out] j JSON value to write to
@param[in] val value to read from
@param[in] val value to read from
*/
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
to_json
(
BasicJsonType
&
j
,
U
&&
val
)
noexcept
(
static
auto
to_json
(
BasicJsonType
&
j
,
TargetType
&&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
))))
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
))))
->
decltype
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
)),
void
())
->
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
}
// namespace nlohmann
This diff is collapsed.
Click to expand it.
include/nlohmann/detail/conversions/from_json.hpp
View file @
c0a8b45b
...
@@ -462,6 +462,8 @@ struct from_json_fn
...
@@ -462,6 +462,8 @@ struct from_json_fn
return
from_json
(
j
,
val
);
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
>
template
<
typename
BasicJsonType
,
typename
T
>
auto
operator
()(
const
BasicJsonType
&
j
,
detail
::
tag
<
T
>
t
)
const
auto
operator
()(
const
BasicJsonType
&
j
,
detail
::
tag
<
T
>
t
)
const
noexcept
(
noexcept
(
from_json
(
j
,
t
)))
noexcept
(
noexcept
(
from_json
(
j
,
t
)))
...
...
This diff is collapsed.
Click to expand it.
single_include/nlohmann/json.hpp
View file @
c0a8b45b
...
@@ -3959,6 +3959,8 @@ struct from_json_fn
...
@@ -3959,6 +3959,8 @@ struct from_json_fn
return
from_json
(
j
,
val
);
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
>
template
<
typename
BasicJsonType
,
typename
T
>
auto
operator
()(
const
BasicJsonType
&
j
,
detail
::
tag
<
T
>
t
)
const
auto
operator
()(
const
BasicJsonType
&
j
,
detail
::
tag
<
T
>
t
)
const
noexcept
(
noexcept
(
from_json
(
j
,
t
)))
noexcept
(
noexcept
(
from_json
(
j
,
t
)))
...
@@ -4553,23 +4555,37 @@ struct adl_serializer
...
@@ -4553,23 +4555,37 @@ struct adl_serializer
This function is usually called by the `get()` function of the
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@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] j JSON value to read from
@param[in,out] val value to write to
@param[in,out] val value to write to
*/
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
from_json
(
BasicJsonType
&&
j
,
U
&
val
)
noexcept
(
static
auto
from_json
(
BasicJsonType
&&
j
,
TargetType
&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
)))
noexcept
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
)))
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
),
void
())
->
decltype
(
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
),
void
())
{
{
::
nlohmann
::
from_json
(
std
::
forward
<
BasicJsonType
>
(
j
),
val
);
::
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
(
static
auto
from_json
(
BasicJsonType
&&
j
)
noexcept
(
noexcept
(
::
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
<
U
>
{}))
->
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
...
@@ -4581,12 +4597,12 @@ struct adl_serializer
@param[in,out] j JSON value to write to
@param[in,out] j JSON value to write to
@param[in] val value to read from
@param[in] val value to read from
*/
*/
template
<
typename
BasicJsonType
,
typename
U
=
ValueType
>
template
<
typename
BasicJsonType
,
typename
TargetType
=
ValueType
>
static
auto
to_json
(
BasicJsonType
&
j
,
U
&&
val
)
noexcept
(
static
auto
to_json
(
BasicJsonType
&
j
,
TargetType
&&
val
)
noexcept
(
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
))))
noexcept
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
TargetType
>
(
val
))))
->
decltype
(
::
nlohmann
::
to_json
(
j
,
std
::
forward
<
U
>
(
val
)),
void
())
->
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
}
// namespace nlohmann
...
...
This diff is collapsed.
Click to expand it.
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