One JSON value: null, a boolean, a number, a string, an array or an object.
More...
#include <json.hpp>
|
| static JsonValue | Float (float f) |
| | A number written with the shortest text that reads back as the same float.
|
| |
One JSON value: null, a boolean, a number, a string, an array or an object.
- Note
- Objects keep their keys in insertion order, and the writer emits them in that order, so the same value always serializes to the same bytes. A number keeps the exact text it was parsed from, so as_float() and as_double() each round the decimal text once, directly to their own type, instead of going through double first.
◆ Array
◆ Object
◆ Type
| Enumerator |
|---|
| Null | |
| Bool | |
| Number | |
| String | |
| Array | |
| Object | |
◆ JsonValue() [1/10]
| pulsatrix::JsonValue::JsonValue |
( |
| ) |
|
|
default |
◆ JsonValue() [2/10]
| pulsatrix::JsonValue::JsonValue |
( |
std::nullptr_t |
| ) |
|
|
inline |
◆ JsonValue() [3/10]
| pulsatrix::JsonValue::JsonValue |
( |
bool |
b | ) |
|
◆ JsonValue() [4/10]
| pulsatrix::JsonValue::JsonValue |
( |
double |
d | ) |
|
A number written with the shortest text that reads back as the same double.
- Exceptions
-
| std::invalid_argument | if d is NaN or infinite, which JSON can't represent. |
◆ JsonValue() [5/10]
| pulsatrix::JsonValue::JsonValue |
( |
int64_t |
i | ) |
|
◆ JsonValue() [6/10]
| pulsatrix::JsonValue::JsonValue |
( |
int |
i | ) |
|
|
inline |
◆ JsonValue() [7/10]
| pulsatrix::JsonValue::JsonValue |
( |
std::string |
s | ) |
|
◆ JsonValue() [8/10]
| pulsatrix::JsonValue::JsonValue |
( |
const char * |
s | ) |
|
|
inline |
◆ JsonValue() [9/10]
| pulsatrix::JsonValue::JsonValue |
( |
Array |
a | ) |
|
◆ JsonValue() [10/10]
| pulsatrix::JsonValue::JsonValue |
( |
Object |
o | ) |
|
◆ add()
| void pulsatrix::JsonValue::add |
( |
std::string |
key, |
|
|
JsonValue |
value |
|
) |
| |
Appends a member to an object. Keys must be unique.
- Exceptions
-
| std::invalid_argument | if this value isn't an object or already has key. |
◆ as_array()
| const Array & pulsatrix::JsonValue::as_array |
( |
| ) |
const |
◆ as_bool()
| bool pulsatrix::JsonValue::as_bool |
( |
| ) |
const |
◆ as_double()
| double pulsatrix::JsonValue::as_double |
( |
| ) |
const |
◆ as_float()
| float pulsatrix::JsonValue::as_float |
( |
| ) |
const |
◆ as_int64()
| int64_t pulsatrix::JsonValue::as_int64 |
( |
| ) |
const |
- Exceptions
-
| std::invalid_argument | also if the number isn't an integer in int64_t's range. |
◆ as_object()
| const Object & pulsatrix::JsonValue::as_object |
( |
| ) |
const |
◆ as_string()
| const std::string & pulsatrix::JsonValue::as_string |
( |
| ) |
const |
◆ find()
| const JsonValue * pulsatrix::JsonValue::find |
( |
std::string_view |
key | ) |
const |
The member named key of an object, or nullptr if there is none.
- Exceptions
-
| std::invalid_argument | if this value isn't an object. |
◆ Float()
| static JsonValue pulsatrix::JsonValue::Float |
( |
float |
f | ) |
|
|
static |
A number written with the shortest text that reads back as the same float.
- Exceptions
-
| std::invalid_argument | if f is NaN or infinite. |
◆ is_null()
| bool pulsatrix::JsonValue::is_null |
( |
| ) |
const |
|
inline |
◆ number_text()
| const std::string & pulsatrix::JsonValue::number_text |
( |
| ) |
const |
A number's text exactly as written or parsed, for example "0.1".
◆ push_back()
| void pulsatrix::JsonValue::push_back |
( |
JsonValue |
value | ) |
|
Appends an element to an array.
- Exceptions
-
| std::invalid_argument | if this value isn't an array. |
◆ type()
| Type pulsatrix::JsonValue::type |
( |
| ) |
const |
|
inline |
◆ JsonParser
◆ ParseJson
Parses one JSON document.
- Note
- Strict: no comments, trailing commas, NaN or Infinity literals, duplicate object keys, invalid UTF-8, unpaired surrogate escapes or trailing content. Nesting deeper than 256 levels is rejected, so a hostile file can't exhaust the stack.
- Exceptions
-
| std::invalid_argument | naming the byte offset of the first error. |
The documentation for this class was generated from the following file: