mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
Consolidate documentation (#3071)
* 🔥 consolidate documentation * ♻️ overwork std specializations * 🚚 move images files to mkdocs * ♻️ fix URLs * 🔧 tweak MkDocs configuration * 🔧 add namespaces * 📝 document deprecations * 📝 document documentation generation * 🚸 improve search * 🚸 add examples * 🚧 start adding documentation for macros * 📝 add note for https://github.com/nlohmann/json/issues/874#issuecomment-1001699139 * 📝 overwork example handling * 📝 fix Markdown tables
This commit is contained in:
41
doc/mkdocs/docs/api/adl_serializer/from_json.md
Normal file
41
doc/mkdocs/docs/api/adl_serializer/from_json.md
Normal file
@ -0,0 +1,41 @@
|
||||
# <small>nlohmann::adl_serializer::</small>from_json
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
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())
|
||||
|
||||
// (2)
|
||||
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||
static auto from_json(BasicJsonType && j) noexcept(
|
||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
|
||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
|
||||
```
|
||||
|
||||
This function is usually called by the [`get()`](../basic_json/get.md) function of the
|
||||
[basic_json](../basic_json) class (either explicit or via conversion operators).
|
||||
|
||||
1. This function is chosen for default-constructible value types.
|
||||
2. This function is chosen for value types which are not default-constructible.
|
||||
|
||||
## Parameters
|
||||
|
||||
`j` (in)
|
||||
: JSON value to read from
|
||||
|
||||
`val` (out)
|
||||
: value to write to
|
||||
|
||||
## Return value
|
||||
|
||||
Copy of the JSON value, converted to `ValueType`
|
||||
|
||||
!!! note
|
||||
|
||||
This documentation page is a stub.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.1.0.
|
35
doc/mkdocs/docs/api/adl_serializer/index.md
Normal file
35
doc/mkdocs/docs/api/adl_serializer/index.md
Normal file
@ -0,0 +1,35 @@
|
||||
# <small>nlohmann::</small>adl_serializer
|
||||
|
||||
```cpp
|
||||
template<typename, typename>
|
||||
struct adl_serializer;
|
||||
```
|
||||
|
||||
Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose
|
||||
`to_json`/`from_json` functions from the types' namespaces.
|
||||
|
||||
It is implemented similar to
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
struct adl_serializer {
|
||||
template<typename BasicJsonType>
|
||||
static void to_json(BasicJsonType& j, const T& value) {
|
||||
// calls the "to_json" method in T's namespace
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void from_json(const BasicJsonType& j, T& value) {
|
||||
// same thing, but with the "from_json" method
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
- [**from_json**](from_json.md) - convert a JSON value to any value type
|
||||
- [**to_json**](to_json.md) - convert any value type to a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.1.0.
|
26
doc/mkdocs/docs/api/adl_serializer/to_json.md
Normal file
26
doc/mkdocs/docs/api/adl_serializer/to_json.md
Normal file
@ -0,0 +1,26 @@
|
||||
# <small>nlohmann::adl_serializer::</small>to_json
|
||||
|
||||
```cpp
|
||||
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())
|
||||
```
|
||||
|
||||
This function is usually called by the constructors of the [basic_json](../basic_json) class.
|
||||
|
||||
## Parameters
|
||||
|
||||
`j` (out)
|
||||
: JSON value to write to
|
||||
|
||||
`val` (in)
|
||||
: value to read from
|
||||
|
||||
!!! note
|
||||
|
||||
This documentation page is a stub.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.1.0.
|
Reference in New Issue
Block a user