mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
📝 add more documentation
This commit is contained in:
72
doc/mkdocs/docs/api/basic_json/dump.md
Normal file
72
doc/mkdocs/docs/api/basic_json/dump.md
Normal file
@ -0,0 +1,72 @@
|
||||
# basic_json::dump
|
||||
|
||||
```cpp
|
||||
string_t dump(const int indent = -1,
|
||||
const char indent_char = ' ',
|
||||
const bool ensure_ascii = false,
|
||||
const error_handler_t error_handler = error_handler_t::strict) const
|
||||
```
|
||||
|
||||
Serialization function for JSON values. The function tries to mimic
|
||||
Python's `json.dumps()` function, and currently supports its `indent`
|
||||
and `ensure_ascii` parameters.
|
||||
|
||||
## Parameters
|
||||
|
||||
`indent` (in)
|
||||
: If indent is nonnegative, then array elements and object
|
||||
members will be pretty-printed with that indent level. An indent level of
|
||||
`0` will only insert newlines. `-1` (the default) selects the most compact
|
||||
representation.
|
||||
|
||||
`indent_char` (in)
|
||||
: The character to use for indentation if `indent` is
|
||||
greater than `0`. The default is ` ` (space).
|
||||
|
||||
`ensure_ascii` (in)
|
||||
: If `ensure_ascii` is true, all non-ASCII characters
|
||||
in the output are escaped with `\uXXXX` sequences, and the result consists
|
||||
of ASCII characters only.
|
||||
|
||||
`error_handler` (in)
|
||||
: how to react on decoding errors; there are three
|
||||
possible values: `strict` (throws and exception in case a decoding error
|
||||
occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD),
|
||||
and `ignore` (ignore invalid UTF-8 sequences during serialization; all
|
||||
bytes are copied to the output unchanged).
|
||||
|
||||
## Return value
|
||||
|
||||
string containing the serialization of the JSON value
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no
|
||||
changes to any JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear.
|
||||
|
||||
## Notes
|
||||
|
||||
Binary values are serialized as object containing two keys:
|
||||
|
||||
- "bytes": an array of bytes as integers
|
||||
- "subtype": the subtype as integer or `#!json null` if the binary has no subtype
|
||||
|
||||
## Example
|
||||
|
||||
The following example shows the effect of different `indent`,
|
||||
`indent_char`, and `ensure_ascii` parameters to the result of the
|
||||
serialization.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/dump.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/dump.output"
|
||||
```
|
11
doc/mkdocs/docs/api/basic_json/index.md
Normal file
11
doc/mkdocs/docs/api/basic_json/index.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Overview
|
||||
|
||||
## Member functions
|
||||
|
||||
### Object inspection
|
||||
|
||||
- [dump](dump.md) - serialization
|
||||
|
||||
## Static functions
|
||||
|
||||
- [meta](meta.md) - returns version information on the library
|
45
doc/mkdocs/docs/api/basic_json/meta.md
Normal file
45
doc/mkdocs/docs/api/basic_json/meta.md
Normal file
@ -0,0 +1,45 @@
|
||||
# basic_json::meta
|
||||
|
||||
```cpp
|
||||
static basic_json meta();
|
||||
```
|
||||
|
||||
This function returns a JSON object with information about the library,
|
||||
including the version number and information on the platform and compiler.
|
||||
|
||||
## Return value
|
||||
|
||||
JSON object holding version information
|
||||
|
||||
key | description
|
||||
----------- | ---------------
|
||||
`compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
|
||||
`copyright` | The copyright line for the library as string.
|
||||
`name` | The name of the library as string.
|
||||
`platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
|
||||
`url` | The URL of the project as string.
|
||||
`version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no
|
||||
changes to any JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
The following code shows an example output of the `meta()`
|
||||
function.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/meta.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/meta.output"
|
||||
```
|
Reference in New Issue
Block a user