Skip to content

Commit 9a612d4

Browse files
authoredMay 10, 2019
Merge pull request #9832 from elpaso/qjson-nlohmann
Fast (and beautiful) json serializing
2 parents 8969360 + 0081ad0 commit 9a612d4

File tree

145 files changed

+22221
-929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+22221
-929
lines changed
 

‎external/nlohmann/adl_serializer.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#pragma once
2+
3+
#include <utility>
4+
5+
#include <nlohmann/detail/conversions/from_json.hpp>
6+
#include <nlohmann/detail/conversions/to_json.hpp>
7+
8+
namespace nlohmann
9+
{
10+
11+
template<typename, typename>
12+
struct adl_serializer
13+
{
14+
/*!
15+
@brief convert a JSON value to any value type
16+
17+
This function is usually called by the `get()` function of the
18+
@ref basic_json class (either explicit or via conversion operators).
19+
20+
@param[in] j JSON value to read from
21+
@param[in,out] val value to write to
22+
*/
23+
template<typename BasicJsonType, typename ValueType>
24+
static auto from_json(BasicJsonType&& j, ValueType& val) noexcept(
25+
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
26+
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
27+
{
28+
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
29+
}
30+
31+
/*!
32+
@brief convert any value type to a JSON value
33+
34+
This function is usually called by the constructors of the @ref basic_json
35+
class.
36+
37+
@param[in,out] j JSON value to write to
38+
@param[in] val value to read from
39+
*/
40+
template <typename BasicJsonType, typename ValueType>
41+
static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
42+
noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
43+
-> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
44+
{
45+
::nlohmann::to_json(j, std::forward<ValueType>(val));
46+
}
47+
};
48+
49+
} // namespace nlohmann

0 commit comments

Comments
 (0)
Please sign in to comment.