JSON object wrapper for Document.
More...
#include <nfx/serialization/json/Document.h>
|
|
| Object () |
| | Default constructor - creates invalid object.
|
| | Object (const Document::Object &other) |
| | Copy constructor.
|
| | Object (Document::Object &&other) noexcept |
| | Move constructor.
|
|
| ~Object ()=default |
| | Destructor.
|
| Document::Object & | operator= (const Document::Object &other) |
| | Copy assignment operator.
|
| Document::Object & | operator= (Document::Object &&other) noexcept |
| | Move assignment operator.
|
| bool | operator== (const Document::Object &other) const |
| | Equality comparison operator.
|
| bool | operator!= (const Document::Object &other) const |
| | Inequality comparison operator.
|
| std::string | toString (int indent=0) const |
| | Convert object to JSON string.
|
| std::vector< uint8_t > | toBytes () const |
| | Convert object to JSON bytes.
|
| size_t | size () const |
| | Get number of fields in object.
|
|
void | clear () |
| | Clear all fields from object.
|
| bool | removeField (std::string_view key) |
| | Remove field from object.
|
| bool | contains (std::string_view fieldName) const |
| | Check if a field exists in this object.
|
| template<JsonValue T> |
| std::optional< T > | get (std::string_view path) const |
| | Get field value by key.
|
| template<JsonValue T> |
| bool | get (std::string_view path, T &value) const |
| | Get field value into output parameter.
|
| template<JsonValue T> |
| void | set (std::string_view path, const T &value) |
| | Set field value (copy version).
|
| template<JsonValue T> |
| void | set (std::string_view path, T &&value) |
| | Set field value (move version).
|
| bool | isValid () const |
| | Check if object is valid.
|
| std::string | lastError () const |
| | Get last error message.
|
| Iterator | begin () const |
| | Get iterator to first field.
|
| Iterator | end () const |
| | Get iterator past last field.
|
JSON object wrapper for Document.
Provides type-safe access to JSON object fields with support for field access, modification, removal, and nested operations using JSON Pointer paths.
Definition at line 335 of file Document.h.
◆ Object() [1/2]
| nfx::serialization::json::Document::Object::Object |
( |
const Document::Object & | other | ) |
|
Copy constructor.
- Parameters
-
◆ Object() [2/2]
Move constructor.
- Parameters
-
◆ begin()
| Iterator nfx::serialization::json::Document::Object::begin |
( |
| ) |
const |
Get iterator to first field.
- Returns
- Iterator pointing to first key-value pair
◆ contains()
| bool nfx::serialization::json::Document::Object::contains |
( |
std::string_view | fieldName | ) |
const |
Check if a field exists in this object.
- Parameters
-
| fieldName | Name of the field to check (simple name, not a path) |
- Returns
- true if the field exists, false otherwise
◆ end()
| Iterator nfx::serialization::json::Document::Object::end |
( |
| ) |
const |
Get iterator past last field.
- Returns
- Iterator representing end position
◆ get() [1/2]
template<JsonValue T>
| std::optional< T > nfx::serialization::json::Document::Object::get |
( |
std::string_view | path | ) |
const |
Get field value by key.
- Template Parameters
-
- Parameters
-
| path | Field key or nested path |
- Returns
- Optional containing field value if exists and correct type
◆ get() [2/2]
template<JsonValue T>
| bool nfx::serialization::json::Document::Object::get |
( |
std::string_view | path, |
|
|
T & | value ) const |
Get field value into output parameter.
- Template Parameters
-
- Parameters
-
| path | Field key or nested path |
| [out] | value | Output parameter to store the result |
- Returns
- true if field exists and was successfully retrieved, false otherwise
◆ isValid()
| bool nfx::serialization::json::Document::Object::isValid |
( |
| ) |
const |
Check if object is valid.
- Returns
- true if object is valid and accessible
◆ lastError()
| std::string nfx::serialization::json::Document::Object::lastError |
( |
| ) |
const |
Get last error message.
- Returns
- String describing the last error
◆ operator!=()
| bool nfx::serialization::json::Document::Object::operator!= |
( |
const Document::Object & | other | ) |
const |
Inequality comparison operator.
- Parameters
-
| other | Object to compare with |
- Returns
- true if objects are not equal
◆ operator=() [1/2]
Copy assignment operator.
- Parameters
-
- Returns
- Reference to this object
◆ operator=() [2/2]
Move assignment operator.
- Parameters
-
- Returns
- Reference to this object
◆ operator==()
| bool nfx::serialization::json::Document::Object::operator== |
( |
const Document::Object & | other | ) |
const |
Equality comparison operator.
- Parameters
-
| other | Object to compare with |
- Returns
- true if objects are equal
◆ removeField()
| bool nfx::serialization::json::Document::Object::removeField |
( |
std::string_view | key | ) |
|
Remove field from object.
- Parameters
-
- Returns
- true if field was removed
◆ set() [1/2]
template<JsonValue T>
| void nfx::serialization::json::Document::Object::set |
( |
std::string_view | path, |
|
|
const T & | value ) |
Set field value (copy version).
- Template Parameters
-
- Parameters
-
| path | Field key or nested path |
| value | Value to copy and set |
◆ set() [2/2]
template<JsonValue T>
| void nfx::serialization::json::Document::Object::set |
( |
std::string_view | path, |
|
|
T && | value ) |
Set field value (move version).
- Template Parameters
-
- Parameters
-
| path | Field key or nested path |
| value | Value to move and set |
◆ size()
| size_t nfx::serialization::json::Document::Object::size |
( |
| ) |
const |
Get number of fields in object.
- Returns
- Number of key-value pairs
◆ toBytes()
| std::vector< uint8_t > nfx::serialization::json::Document::Object::toBytes |
( |
| ) |
const |
Convert object to JSON bytes.
- Returns
- JSON byte representation
◆ toString()
| std::string nfx::serialization::json::Document::Object::toString |
( |
int | indent = 0 | ) |
const |
Convert object to JSON string.
- Parameters
-
| indent | Indentation level for pretty printing
- 0: compact output (no whitespace)
- >0: pretty-print with specified spaces per level
|
- Returns
- JSON string representation
◆ Document
◆ Document_impl
| friend class Document_impl |
|
friend |
The documentation for this class was generated from the following file: