|
nfx-serialization 0.3.0
Cross-platform C++ JSON serialization library with extensible trait capabilities
|
Generic JSON document abstraction for serialization. More...
#include <nfx/serialization/json/Document.h>
Classes | |
| class | Object |
| JSON object wrapper for Document. More... | |
| class | Array |
| JSON array wrapper for Document. More... | |
| class | PathView |
| Path iterator for traversing all paths in a JSON document. More... | |
Public Member Functions | |
| Document () | |
| Default constructor - creates an empty document. | |
| Document (const Document &other) | |
| Copy constructor. | |
| Document (Document &&other) noexcept | |
| Move constructor. | |
| ~Document () | |
| Destructor - cleans up document resources. | |
| Document & | operator= (const Document &other) |
| Copy assignment operator. | |
| Document & | operator= (Document &&other) noexcept |
| Move assignment operator. | |
| bool | operator== (const Document &other) const |
| Equality comparison operator. | |
| bool | operator!= (const Document &other) const |
| Inequality comparison operator. | |
| std::string | toString (int indent=0) const |
| Convert document to JSON string. | |
| std::vector< uint8_t > | toBytes () const |
| Convert document to JSON bytes. | |
| void | merge (const Document &other, bool overwriteArrays=true) |
| Merge another document into this one. | |
| void | update (std::string_view path, const Document &value) |
| Update value at specific path. | |
| bool | contains (std::string_view path) const |
| Check if a value exists at the specified path. | |
| template<JsonValue T> | |
| std::optional< T > | get (std::string_view path) const |
| Get typed value at specified path. | |
| template<JsonValue T> | |
| bool | get (std::string_view path, T &value) const |
| Get typed value at specified path into output parameter. | |
| template<JsonValue T> | |
| void | set (std::string_view path, const T &value) |
| Set typed value at specified path (copy version). | |
| template<JsonValue T> | |
| void | set (std::string_view path, T &&value) |
| Set typed value at specified path (move version). | |
| template<JsonContainer T> | |
| void | set (std::string_view path) |
| Create empty container at specified path. | |
| void | setNull (std::string_view path) |
| Set null value at specified path. | |
| template<JsonCheckable T> | |
| bool | is (std::string_view path) const |
| Check if value at path is of specified type. | |
| bool | isNull (std::string_view path) const |
| Check if value at path is null. | |
| bool | isValid () const |
| Check if document is in valid state. | |
| std::string | lastError () const |
| Get last error message. | |
Static Public Member Functions | |
| static std::optional< Document > | fromString (std::string_view jsonStr) |
| Create document from JSON string. | |
| static bool | fromString (std::string_view jsonStr, Document &doc) |
| Parse JSON string into existing document. | |
| static std::optional< Document > | fromBytes (std::span< const uint8_t > bytes) |
| Create document from JSON bytes. | |
| static bool | fromBytes (std::span< const uint8_t > bytes, Document &doc) |
| Parse JSON bytes into existing document. | |
Friends | |
| class | Document_impl |
| class | SchemaValidator_impl |
Generic JSON document abstraction for serialization.
Provides a high-level interface for JSON document manipulation with support for JSON Pointer paths, type-safe value access, and nested object/array operations.
Definition at line 58 of file Document.h.
| nfx::serialization::json::Document::Document | ( | const Document & | other | ) |
Copy constructor.
| other | The document to copy from |

|
noexcept |
Move constructor.
| other | The document to move from |

| bool nfx::serialization::json::Document::contains | ( | std::string_view | path | ) | const |
Check if a value exists at the specified path.
| path | JSON Pointer path (e.g., "/user/name") or dot notation (e.g., "user.name") |
|
static |
Create document from JSON bytes.
| bytes | JSON bytes to parse (accepts vector, array, or raw pointer+size) |
|
static |
Parse JSON bytes into existing document.
| bytes | JSON bytes to parse (accepts vector, array, or raw pointer+size) | |
| [out] | doc | Document to populate |

|
static |
Create document from JSON string.
| jsonStr | JSON string to parse |
|
static |
Parse JSON string into existing document.
| jsonStr | JSON string to parse | |
| [out] | doc | Document to populate |

| std::optional< T > nfx::serialization::json::Document::get | ( | std::string_view | path | ) | const |
Get typed value at specified path.
| T | Type to retrieve (string, int, double, bool, Document, Object, Array) |
| path | JSON Pointer path to value |
| bool nfx::serialization::json::Document::get | ( | std::string_view | path, |
| T & | value ) const |
Get typed value at specified path into output parameter.
| T | Type to retrieve (string, int, double, bool, Document, Object, Array) |
| path | JSON Pointer path to value | |
| [out] | value | Output parameter to store the result |
| bool nfx::serialization::json::Document::is | ( | std::string_view | path | ) | const |
Check if value at path is of specified type.
| T | Type to check for |
| path | JSON Pointer path to check |
| bool nfx::serialization::json::Document::isNull | ( | std::string_view | path | ) | const |
Check if value at path is null.
| path | JSON Pointer path to check |
| bool nfx::serialization::json::Document::isValid | ( | ) | const |
Check if document is in valid state.
| std::string nfx::serialization::json::Document::lastError | ( | ) | const |
Get last error message.
| void nfx::serialization::json::Document::merge | ( | const Document & | other, |
| bool | overwriteArrays = true ) |
Merge another document into this one.
| other | Document to merge |
| overwriteArrays | Whether to overwrite arrays or merge them |

| bool nfx::serialization::json::Document::operator!= | ( | const Document & | other | ) | const |
Inequality comparison operator.
| other | The document to compare with |

Copy assignment operator.
| other | The document to copy from |

Move assignment operator.
| other | The document to move from |

| bool nfx::serialization::json::Document::operator== | ( | const Document & | other | ) | const |
Equality comparison operator.
| other | The document to compare with |

| void nfx::serialization::json::Document::set | ( | std::string_view | path | ) |
Create empty container at specified path.
| T | Container type (Document, Object, Array) |
| path | JSON Pointer path where to create container |
| void nfx::serialization::json::Document::set | ( | std::string_view | path, |
| const T & | value ) |
Set typed value at specified path (copy version).
| T | Type to set (string, int, double, bool, Document, Object, Array) |
| path | JSON Pointer path where to set value |
| value | Value to set (copied) |
| void nfx::serialization::json::Document::set | ( | std::string_view | path, |
| T && | value ) |
Set typed value at specified path (move version).
| T | Type to set (string, int, double, bool, Document, Object, Array) |
| path | JSON Pointer path where to set value |
| value | Value to set (moved) |
| void nfx::serialization::json::Document::setNull | ( | std::string_view | path | ) |
Set null value at specified path.
| path | JSON Pointer path where to set null |
| std::vector< uint8_t > nfx::serialization::json::Document::toBytes | ( | ) | const |
Convert document to JSON bytes.
| std::string nfx::serialization::json::Document::toString | ( | int | indent = 0 | ) | const |
Convert document to JSON string.
| indent | Indentation level for pretty printing
|
| void nfx::serialization::json::Document::update | ( | std::string_view | path, |
| const Document & | value ) |
Update value at specific path.
| path | JSON Pointer path to update |
| value | New value to set |

|
friend |
Definition at line 72 of file Document.h.
|
friend |
Definition at line 73 of file Document.h.