Devel Lib
Devel::IO::CJsonObject Class Reference

A class that encapsulates a JSON object. More...

#include <JsonObject.h>

Inheritance diagram for Devel::IO::CJsonObject:
Collaboration diagram for Devel::IO::CJsonObject:

Public Member Functions

 CJsonObject ()
 Default constructor.
 
 CJsonObject (const CJsonObject &i_oOther)
 Copy constructor. More...
 
 CJsonObject (CJsonObject &&i_oOther) noexcept
 Move constructor. More...
 
virtual ~CJsonObject ()
 Virtual destructor.
 
CJsonObjectfind (std::string_view i_stName)
 Finds a value in the JSON object. More...
 
std::vector< std::string > getKeys ()
 Returns the keys of the JSON object. More...
 
CJsonArray toArray () const
 Converts the JSON object to a JSON array. More...
 
Threading::CMutexmutex ()
 Returns a reference to the mutex. More...
 
EJsonType type () const
 Returns the type of the JSON object. More...
 
CJsonObjectget (const std::string_view i_stName)
 Gets the value associated with the specified name. More...
 
void setNull ()
 Sets the type of the JSON object to null.
 
uint64 toUInt64 () const
 Converts the JSON object to a 64-bit unsigned integer. More...
 
int64 toInt64 () const
 Converts the JSON object to a 64-bit signed integer. More...
 
int toInt () const
 Converts the JSON object to an integer. More...
 
uint toUInt () const
 Converts the JSON object to an unsigned integer. More...
 
float toFloat () const
 Converts the JSON object to a float. More...
 
double toDouble () const
 Converts the JSON object to a double. More...
 
bool toBool () const
 Converts the JSON object to a boolean. More...
 
bool isNull () const
 Checks if the JSON object is null. More...
 
CJsonObjectoperator= (const CJsonObject &i_oOther)
 Assignment operator overloads for various data types including CJsonObject, CJsonArray, char, string, uint64, uint, int64, float, double, int, and bool.
 
CJsonObjectoperator= (CJsonObject &&i_oOther) noexcept
 
CJsonObjectoperator= (const CJsonArray &i_oOther)
 
CJsonObjectoperator= (const char *i_stValue)
 
CJsonObjectoperator= (const std::string &i_stValue)
 
CJsonObjectoperator= (const uint64 i_nValue)
 
CJsonObjectoperator= (const uint i_nValue)
 
CJsonObjectoperator= (const int64 i_nValue)
 
CJsonObjectoperator= (const float i_fValue)
 
CJsonObjectoperator= (const double i_dValue)
 
CJsonObjectoperator= (const int i_nValue)
 
CJsonObjectoperator= (const bool i_bState)
 
CJsonObjectoperator[] (const std::string_view i_stKey)
 Subscript operator overload for string key. More...
 

Friends

class CJsonDocument
 Allows CJsonDocument to access private members of CJsonObject.
 

Detailed Description

A class that encapsulates a JSON object.

This class represents a JSON object and provides methods for accessing and manipulating its data.

Example

// Creating a new JSON object
// Setting a string value
jsonObject["name"] = "John Doe";
// Setting a number value
jsonObject["age"] = 30;
// Accessing values
std::string name = jsonObject["name"].toString();
int age = jsonObject["age"].toInt();
A class that encapsulates a JSON object.
Definition: JsonObject.h:50
int toInt() const
Converts the JSON object to an integer.
Definition: JsonObject.h:145

Constructor & Destructor Documentation

◆ CJsonObject() [1/2]

Devel::IO::CJsonObject::CJsonObject ( const CJsonObject i_oOther)
inline

Copy constructor.

Parameters
i_oOther- The CJsonObject instance to copy.

◆ CJsonObject() [2/2]

Devel::IO::CJsonObject::CJsonObject ( CJsonObject &&  i_oOther)
inlinenoexcept

Move constructor.

Parameters
i_oOther- The CJsonObject instance to move.

Member Function Documentation

◆ find()

Devel::IO::CJsonObject * Devel::IO::CJsonObject::find ( std::string_view  i_stName)

Finds a value in the JSON object.

Parameters
i_stName- The name of the value to find.
Returns
A pointer to the value, if found. Otherwise, returns nullptr.

◆ get()

CJsonObject& Devel::IO::CJsonObject::get ( const std::string_view  i_stName)
inline

Gets the value associated with the specified name.

Parameters
i_stNameThe name of the value to get.
Returns
The value associated with the specified name.

◆ getKeys()

std::vector< std::string > Devel::IO::CJsonObject::getKeys ( )

Returns the keys of the JSON object.

Returns
A vector of keys (strings) of the JSON object.

◆ isNull()

bool Devel::IO::CJsonObject::isNull ( ) const
inline

Checks if the JSON object is null.

Returns
True if the JSON object is null; otherwise, false.

◆ mutex()

Threading::CMutex& Devel::IO::CJsonObject::mutex ( )
inline

Returns a reference to the mutex.

Returns
A reference to the mutex.

◆ operator[]()

CJsonObject& Devel::IO::CJsonObject::operator[] ( const std::string_view  i_stKey)
inline

Subscript operator overload for string key.

Parameters
i_stKeyThe key to access.
Returns
The value associated with the specified key.

◆ toArray()

Devel::IO::CJsonArray Devel::IO::CJsonObject::toArray ( ) const

Converts the JSON object to a JSON array.

Returns
A CJsonArray object.

◆ toBool()

bool Devel::IO::CJsonObject::toBool ( ) const
inline

Converts the JSON object to a boolean.

Returns
The JSON object as a boolean.

◆ toDouble()

double Devel::IO::CJsonObject::toDouble ( ) const
inline

Converts the JSON object to a double.

Returns
The JSON object as a double.

◆ toFloat()

float Devel::IO::CJsonObject::toFloat ( ) const
inline

Converts the JSON object to a float.

Returns
The JSON object as a float.

◆ toInt()

int Devel::IO::CJsonObject::toInt ( ) const
inline

Converts the JSON object to an integer.

Returns
The JSON object as an integer.

◆ toInt64()

int64 Devel::IO::CJsonObject::toInt64 ( ) const
inline

Converts the JSON object to a 64-bit signed integer.

Returns
The JSON object as a 64-bit signed integer.

◆ toUInt()

uint Devel::IO::CJsonObject::toUInt ( ) const
inline

Converts the JSON object to an unsigned integer.

Returns
The JSON object as an unsigned integer.

◆ toUInt64()

uint64 Devel::IO::CJsonObject::toUInt64 ( ) const
inline

Converts the JSON object to a 64-bit unsigned integer.

Returns
The JSON object as a 64-bit unsigned integer.

◆ type()

EJsonType Devel::IO::CJsonObject::type ( ) const
inline

Returns the type of the JSON object.

Returns
The type of the JSON object.

The documentation for this class was generated from the following files: