mirror of
https://github.com/nlohmann/json.git
synced 2026-02-19 18:06:25 +00:00
Clean up and document project files (#4560)
This commit is contained in:
@@ -20,7 +20,7 @@ Checks whether the input is valid JSON.
|
||||
The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted
|
||||
respectively as UTF-8, UTF-16 and UTF-32.
|
||||
|
||||
Unlike the [`parse`](parse.md) function, this function neither throws an exception in case of invalid JSON input
|
||||
Unlike the [`parse()`](parse.md) function, this function neither throws an exception in case of invalid JSON input
|
||||
(i.e., a parse error) nor creates diagnostic information.
|
||||
|
||||
## Template parameters
|
||||
@@ -29,7 +29,7 @@ Unlike the [`parse`](parse.md) function, this function neither throws an excepti
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer (throws if null)
|
||||
- a `#!c FILE` pointer (throws if null)
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters (throws if null)
|
||||
- a `std::string`
|
||||
@@ -66,7 +66,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an empty input like a null `FILE*` or `char*` pointer.
|
||||
Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an empty input like a null `#!c FILE*` or `#!c char*` pointer.
|
||||
|
||||
## Complexity
|
||||
|
||||
|
||||
68
docs/mkdocs/docs/api/basic_json/end_pos.md
Normal file
68
docs/mkdocs/docs/api/basic_json/end_pos.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# <small>nlohmann::basic_json::</small>end_pos
|
||||
|
||||
```cpp
|
||||
#if JSON_DIAGNOSTIC_POSITIONS
|
||||
constexpr std::size_t end_pos() const noexcept;
|
||||
#endif
|
||||
```
|
||||
|
||||
Returns the position immediately following the last character of the JSON string from which the value was parsed from.
|
||||
|
||||
| JSON type | return value |
|
||||
|-----------|-----------------------------------|
|
||||
| object | position after the closing `}` |
|
||||
| array | position after the closing `]` |
|
||||
| string | position after the closing `"` |
|
||||
| number | position after the last character |
|
||||
| boolean | position after `e` |
|
||||
| null | position after `l` |
|
||||
|
||||
## Return value
|
||||
|
||||
the position of the character _following_ the last character of the given value in the parsed JSON string, if the
|
||||
value was created by the [`parse`](parse.md) function, or `std::string::npos` if the value was constructed otherwise
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
!!! note "Note"
|
||||
|
||||
The function is only available if macro [`JSON_DIAGNOSTIC_POSITIONS`](../macros/json_diagnostic_positions.md) has
|
||||
been defined to `#!cpp 1` before including the library header.
|
||||
|
||||
!!! warning "Invalidation"
|
||||
|
||||
The returned positions are only valid as long as the JSON value is not changed. The positions are *not* updated
|
||||
when the JSON value is changed.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example "Example"
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/diagnostic_positions.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
--8<-- "examples/diagnostic_positions.output"
|
||||
```
|
||||
|
||||
The output shows the start/end positions of all the objects and fields in the JSON string.
|
||||
|
||||
## See also
|
||||
|
||||
- [start_pos](start_pos.md) to access the start position
|
||||
- [JSON_DIAGNOSTIC_POSITIONS](../macros/json_diagnostic_positions.md) for an overview of the diagnostic positions
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.0.
|
||||
@@ -156,9 +156,9 @@ The class satisfies the following concept requirements:
|
||||
- [(constructor)](basic_json.md)
|
||||
- [(destructor)](~basic_json.md)
|
||||
- [**operator=**](operator=.md) - copy assignment
|
||||
- [**array**](array_t.md) (_static_) - explicitly create an array
|
||||
- [**array**](array.md) (_static_) - explicitly create an array
|
||||
- [**binary**](binary.md) (_static_) - explicitly create a binary array
|
||||
- [**object**](object_t.md) (_static_) - explicitly create an object
|
||||
- [**object**](object.md) (_static_) - explicitly create an object
|
||||
|
||||
### Object inspection
|
||||
|
||||
@@ -181,6 +181,11 @@ Functions to inspect the type of a JSON value.
|
||||
- [**is_binary**](is_binary.md) - return whether value is a binary array
|
||||
- [**is_discarded**](is_discarded.md) - return whether value is discarded
|
||||
|
||||
Optional functions to access the [diagnostic positions](../macros/json_diagnostic_positions.md).
|
||||
|
||||
- [**start_pos**](start_pos.md) - return the start position of the value
|
||||
- [**end_pos**](end_pos.md) - return the one past the end position of the value
|
||||
|
||||
### Value access
|
||||
|
||||
Direct access to the stored value of a JSON value.
|
||||
|
||||
68
docs/mkdocs/docs/api/basic_json/start_pos.md
Normal file
68
docs/mkdocs/docs/api/basic_json/start_pos.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# <small>nlohmann::basic_json::</small>start_pos
|
||||
|
||||
```cpp
|
||||
#if JSON_DIAGNOSTIC_POSITIONS
|
||||
constexpr std::size_t start_pos() const noexcept;
|
||||
#endif
|
||||
```
|
||||
|
||||
Returns the position of the first character in the JSON string from which the value was parsed from.
|
||||
|
||||
| JSON type | return value |
|
||||
|-----------|------------------------------------------------|
|
||||
| object | position of the opening `{` |
|
||||
| array | position of the opening `[` |
|
||||
| string | position of the opening `"` |
|
||||
| number | position of the first character |
|
||||
| boolean | position of `t` for `true` and `f` for `false` |
|
||||
| null | position of `n` |
|
||||
|
||||
## Return value
|
||||
|
||||
the position of the first character of the value in the parsed JSON string, if the value was created by the
|
||||
[`parse`](parse.md) function, or `std::string::npos` if the value was constructed otherwise
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
!!! note "Note"
|
||||
|
||||
The function is only available if macro [`JSON_DIAGNOSTIC_POSITIONS`](../macros/json_diagnostic_positions.md) has
|
||||
been defined to `#!cpp 1` before including the library header.
|
||||
|
||||
!!! warning "Invalidation"
|
||||
|
||||
The returned positions are only valid as long as the JSON value is not changed. The positions are *not* updated
|
||||
when the JSON value is changed.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example "Example"
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/diagnostic_positions.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
--8<-- "examples/diagnostic_positions.output"
|
||||
```
|
||||
|
||||
The output shows the start/end positions of all the objects and fields in the JSON string.
|
||||
|
||||
## See also
|
||||
|
||||
- [end_pos](end_pos.md) to access the end position
|
||||
- [JSON_DIAGNOSTIC_POSITIONS](../macros/json_diagnostic_positions.md) for an overview of the diagnostic positions
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.0.
|
||||
Reference in New Issue
Block a user