mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
📝 add more API documentation
This commit is contained in:
21
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
Normal file
21
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
Normal file
@ -0,0 +1,21 @@
|
||||
# basic_json::cbor_tag_handler_t
|
||||
|
||||
```cpp
|
||||
enum class cbor_tag_handler_t
|
||||
{
|
||||
error,
|
||||
ignore
|
||||
};
|
||||
```
|
||||
|
||||
This enumeration is used in the [`from_cbor`](from_cbor.md) function to choose how to treat tags:
|
||||
|
||||
error
|
||||
: throw a `parse_error` exception in case of a tag
|
||||
|
||||
ignore
|
||||
: ignore tags
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.9.0.
|
65
doc/mkdocs/docs/api/basic_json/exception.md
Normal file
65
doc/mkdocs/docs/api/basic_json/exception.md
Normal file
@ -0,0 +1,65 @@
|
||||
# basic_json::exception
|
||||
|
||||
```cpp
|
||||
class exception : public std::exception;
|
||||
```
|
||||
|
||||
This class is an extension of [`std::exception`](https://en.cppreference.com/w/cpp/error/exception) objects with a
|
||||
member `id` for exception ids. It is used as the base class for all exceptions thrown by the `basic_json` class. This
|
||||
class can hence be used as "wildcard" to catch exceptions, see example below.
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- json::exception
|
||||
json::exception <|-- json::parse_error
|
||||
json::exception <|-- json::invalid_iterator
|
||||
json::exception <|-- json::type_error
|
||||
json::exception <|-- json::out_of_range
|
||||
json::exception <|-- json::other_error
|
||||
|
||||
interface std::exception {}
|
||||
|
||||
class json::exception #FFFF00 {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
|
||||
class json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
```
|
||||
|
||||
Subclasses:
|
||||
|
||||
- `parse_error` for exceptions indicating a parse error
|
||||
- `invalid_iterator` for exceptions indicating errors with iterators
|
||||
- `type_error` for exceptions indicating executing a member function with a wrong type
|
||||
- `out_of_range` for exceptions indicating access out of the defined range
|
||||
- `other_error` for exceptions indicating other library errors
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
|
||||
## Member variables
|
||||
|
||||
- **id** - the id of the exception
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how arbitrary library exceptions can be caught.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/exception.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/exception.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
@ -53,7 +53,8 @@ Deserializes a given input to a JSON value using the CBOR (Concise Binary Object
|
||||
: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default)
|
||||
|
||||
`tag_handler` (in)
|
||||
: how to treat CBOR tags (optional, `error` by default)
|
||||
: how to treat CBOR tags (optional, `error` by default); see [`cbor_tag_handler_t`](cbor_tag_handler_t.md) for more
|
||||
information
|
||||
|
||||
## Return value
|
||||
|
||||
|
15
doc/mkdocs/docs/api/basic_json/get_allocator.md
Normal file
15
doc/mkdocs/docs/api/basic_json/get_allocator.md
Normal file
@ -0,0 +1,15 @@
|
||||
# basic_json::get_allocator
|
||||
|
||||
```cpp
|
||||
static allocator_type get_allocator();
|
||||
```
|
||||
|
||||
Returns the allocator associated with the container.
|
||||
|
||||
## Return value
|
||||
|
||||
associated allocator
|
||||
|
||||
## Version history
|
||||
|
||||
- Unknown.
|
@ -52,14 +52,14 @@ Todo
|
||||
- [**json_pointer**](../json_pointer.md) - JSON Pointer implementation
|
||||
- json_serializer
|
||||
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
|
||||
- cbor_tag_handler_t
|
||||
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
|
||||
- initializer_list_t
|
||||
- input_format_t
|
||||
- [**input_format_t**](input_format_t.md) - type to choose the format to parse
|
||||
- json_sax_t
|
||||
|
||||
### Exceptions
|
||||
|
||||
- exception
|
||||
- [**exception**](exception.md) - general exception of the `basic_json` class
|
||||
- parse_error
|
||||
- invalid_iterator
|
||||
- type_error
|
||||
@ -225,7 +225,7 @@ Access to the JSON value
|
||||
## Static functions
|
||||
|
||||
- [**meta**](meta.md) - returns version information on the library
|
||||
- get_allocator - returns the allocator associated with the container
|
||||
- [**get_allocator**](get_allocator.md) - returns the allocator associated with the container
|
||||
|
||||
### Binary formats
|
||||
|
||||
|
32
doc/mkdocs/docs/api/basic_json/input_format_t.md
Normal file
32
doc/mkdocs/docs/api/basic_json/input_format_t.md
Normal file
@ -0,0 +1,32 @@
|
||||
# basic_json::input_format_t
|
||||
|
||||
```cpp
|
||||
enum class input_format_t {
|
||||
json,
|
||||
cbor,
|
||||
msgpack,
|
||||
ubjson,
|
||||
bson
|
||||
};
|
||||
```
|
||||
|
||||
This enumeration is used in the [`sax_parse`](sax_parse.md) function to choose the input format to parse:
|
||||
|
||||
json
|
||||
: JSON (JavaScript Object Notation)
|
||||
|
||||
cbor
|
||||
: CBOR (Concise Binary Object Representation)
|
||||
|
||||
msgpack
|
||||
: MessagePack
|
||||
|
||||
ubjson
|
||||
: UBJSON (Universal Binary JSON)
|
||||
|
||||
bson
|
||||
: BSON (Binary JSON)
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.2.0.
|
@ -55,7 +55,8 @@ The SAX event lister must follow the interface of `json_sax`.
|
||||
: SAX event listener
|
||||
|
||||
`format` (in)
|
||||
: the format to parse (JSON, CBOR, MessagePack, or UBJSON) (optional, `input_format_t::json` by default)
|
||||
: the format to parse (JSON, CBOR, MessagePack, or UBJSON) (optional, `input_format_t::json` by default), see
|
||||
[`input_format_t`](input_format_t.md) for more information
|
||||
|
||||
`strict` (in)
|
||||
: whether the input has to be consumed completely (optional, `#!cpp true` by default)
|
||||
|
Reference in New Issue
Block a user