A class for representing and handling a JSON document.
More...
#include <JsonDocument.h>
A class for representing and handling a JSON document.
This class encapsulates a JSON object and provides functions for parsing and serializing JSON. Example
doc.
parse(
"{\"key\": \"value\"}");
std::string jsonString = doc.
serialize(
true);
A class for representing and handling a JSON document.
Definition: JsonDocument.h:35
CJsonObject & getObject(const std::string &i_stKey)
Gets a JSON object by key from the encapsulated JSON object.
Definition: JsonDocument.h:239
std::string serialize(bool i_bFormatted)
Serializes the encapsulated JSON object into a JSON string.
Definition: JsonDocument.cpp:406
void parse(const std::string &i_stJson)
Parses a JSON string.
Definition: JsonDocument.cpp:378
A class that encapsulates a JSON object.
Definition: JsonObject.h:50
- Exceptions
-
| std::runtime_error | If the format or encoding of the JSON is invalid. |
◆ CJsonDocument() [1/4]
| Devel::IO::CJsonDocument::CJsonDocument |
( |
| ) |
|
◆ CJsonDocument() [2/4]
| Devel::IO::CJsonDocument::CJsonDocument |
( |
const std::string & |
i_stJson | ) |
|
◆ CJsonDocument() [3/4]
| Devel::IO::CJsonDocument::CJsonDocument |
( |
const CJsonDocument & |
i_oOther | ) |
|
|
inline |
◆ CJsonDocument() [4/4]
| Devel::IO::CJsonDocument::CJsonDocument |
( |
CJsonDocument && |
i_oOther | ) |
|
|
inlinenoexcept |
◆ clear()
| void Devel::IO::CJsonDocument::clear |
( |
| ) |
|
|
inline |
Clears the encapsulated JSON object.
Clears the encapsulated JSON object.
◆ getObject()
| CJsonObject& Devel::IO::CJsonDocument::getObject |
( |
const std::string & |
i_stKey | ) |
|
|
inline |
Gets a JSON object by key from the encapsulated JSON object.
- Parameters
-
| i_stKey | - The key of the JSON object to get. |
- Returns
- The JSON object with the given key.
Gets a JSON object by key from the encapsulated JSON object.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ operator[]()
| CJsonObject& Devel::IO::CJsonDocument::operator[] |
( |
const std::string & |
i_stKey | ) |
|
|
inline |
◆ parse()
| void Devel::IO::CJsonDocument::parse |
( |
const std::string & |
i_stJson | ) |
|
Parses a JSON string.
- Parameters
-
| i_stJson | - The JSON string to parse. |
Parses a JSON string and populates the encapsulated JSON object.
◆ serialize()
| std::string Devel::IO::CJsonDocument::serialize |
( |
bool |
i_bFormatted = false | ) |
|
Serializes the encapsulated JSON object into a JSON string.
- Parameters
-
| i_bFormatted | - Whether the output string should be pretty-printed. |
- Returns
- The serialized JSON string.
Serializes the encapsulated JSON object into a JSON string.
◆ toObject()
Gets the encapsulated JSON object.
- Returns
- The encapsulated JSON object.
Gets the encapsulated JSON object.
The documentation for this class was generated from the following files:
- /home/runner/work/devel-library/devel-library/IO/JsonDocument/JsonDocument.h
- /home/runner/work/devel-library/devel-library/IO/JsonDocument/JsonDocument.cpp