• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# <small>nlohmann::</small>adl_serializer
2
3```cpp
4template<typename, typename>
5struct adl_serializer;
6```
7
8Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose
9`to_json`/`from_json` functions from the types' namespaces.
10
11It is implemented similar to
12
13```cpp
14template<typename ValueType>
15struct adl_serializer {
16    template<typename BasicJsonType>
17    static void to_json(BasicJsonType& j, const T& value) {
18        // calls the "to_json" method in T's namespace
19    }
20
21    template<typename BasicJsonType>
22    static void from_json(const BasicJsonType& j, T& value) {
23        // same thing, but with the "from_json" method
24    }
25};
26```
27
28## Member functions
29
30- [**from_json**](from_json.md) - convert a JSON value to any value type
31- [**to_json**](to_json.md) - convert any value type to a JSON value
32
33## Version history
34
35- Added in version 2.1.0.
36