|
Devel Lib
|
Represents a JSON data type with serialization and deserialization functionality. More...
#include <JsonSerializableType.h>


Public Member Functions | |
| bool | doDeserialize (IO::CJsonObject &i_oObject, const bool i_bIsStrict=false) |
| Deserializes the object from a JSON object. More... | |
| bool | doSerialize (IO::CJsonObject &i_oObject, const bool i_bIsStrict=false) const |
| Serializes the object to a JSON object. More... | |
| size_t | size () const override |
| Retrieves the size of the object. More... | |
| template<typename TJsonFieldName , std::enable_if_t< std::is_same_v< CJsonFieldName, TJsonFieldName >, bool > = true> | |
| IJsonType & | operator= (const TJsonFieldName &i_tValue) |
| Assigns a JSON field name to the object. More... | |
| template<typename TJsonFieldName , std::enable_if_t< std::is_same_v< CJsonFieldName, TJsonFieldName >, bool > = true> | |
| IJsonType & | operator= (TJsonFieldName &&i_tValue) |
| Assigns a JSON field name to the object (move assignment). More... | |
Public Member Functions inherited from Devel::Serializing::IData< int > | |
| virtual | ~IData ()=default |
| Default destructor. | |
| bool | doSerialize (IO::CWriteStream &i_oStream) const |
| Serializes the data to a write stream. More... | |
| bool | doDeserialize (IO::CReadStream &i_oStream) |
| Deserializes the data from a read stream. More... | |
| bool | doDeserialize (const char *i_szString) |
| Deserializes the data from a string. More... | |
| bool | doDeserialize (std::vector< std::string >::const_iterator &i_oIt, const std::vector< std::string >::const_iterator &i_oItEnd) |
| Deserializes the data from a range of strings. More... | |
| virtual bool | isHidden () const |
| Returns whether the field is hidden. More... | |
| virtual SCompareData | compareData () const |
| Returns the compare data for the data field. More... | |
| auto | begin () const |
| Returns an iterator pointing to the beginning of the value. More... | |
| auto | end () const |
| Returns an iterator pointing to the end of the value. More... | |
| auto & | operator[] (const size_t i_nIndex) |
| Returns a reference to the value at the specified index. More... | |
| const auto & | operator[] (const size_t i_nIndex) const |
| Returns a const reference to the value at the specified index. More... | |
| SerializerEnableIfNotArithmetic (IData< int > &) operator--() | |
| Pre-decrement operator. More... | |
| SerializerEnableIfNotArithmetic (IData< int > &) operator--(int) | |
| Post-decrement operator. More... | |
| SerializerEnableIfNotArithmetic (IData< int > &) operator++() | |
| Pre-increment operator. More... | |
| SerializerEnableIfNotArithmetic (IData< int > &) operator++(int) | |
| Post-increment operator. More... | |
Public Member Functions inherited from Devel::Serializing::IValue< int > | |
| IValue (TArgs... i_tArgs) | |
Constructs an IValue object with the specified arguments. More... | |
| const int & | value () const |
| Returns the value. More... | |
| int & | value () |
| Returns a reference to the value. More... | |
Protected Member Functions | |
| IJsonType (const CJsonFieldName i_oFieldName) | |
Constructs an IJsonType object with the specified JSON field name. More... | |
| virtual | ~IJsonType ()=default |
| Destructor. | |
| virtual bool | onDeserialize (IO::CJsonObject &i_oObject, const bool i_bIsStrict) |
| Called during deserialization to populate the object from a JSON object. More... | |
| virtual bool | onSerialize (IO::CJsonObject &i_oObject, const bool i_bIsStrict) const |
| Called during serialization to convert the object to a JSON object. More... | |
| virtual bool | onDeserialize (IO::CJsonObject &i_oObject) |
| Called during deserialization to populate the object from a JSON object (non-strict mode). More... | |
| virtual bool | onSerialize (IO::CJsonObject &i_oObject) const |
| Called during deserialization to populate the object from a JSON object (non-strict mode). More... | |
| bool | serialize (IO::CJsonObject &i_oObject, const bool i_bIsStrict=false) const |
| Serializes the data to a JSON object. More... | |
| std::string_view | name () const |
| Retrieves the name of the JSON field. More... | |
| bool | isNull () const |
| Checks if the JSON field is null. More... | |
| void | setNull (bool i_bState) |
| Sets the null state of the JSON field. More... | |
| IO::CJsonObject * | getObject (IO::CJsonObject &i_oObject, const bool i_bIsStrict) |
| Retrieves the JSON object for the specified JSON field. More... | |
| bool | checkSerializeObject (IO::CJsonObject &i_oObject, const bool i_bIsStrict) const |
| Checks if serialization of the object is allowed and handles null fields. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Devel::Serializing::IValue< int > | |
| int | m_tValue |
| The value. | |
Represents a JSON data type with serialization and deserialization functionality.
| T | The underlying data type of the JSON field. |
| TData | The base class for serialization and deserialization operations. Example |
This class represents a JSON data type and provides serialization and deserialization functionality.
Here is an example of how to use the IJsonType class:
This example demonstrates the creation of a custom JSON data type called MyJsonType, which derives from IJsonType. It overrides the onDeserialize and onSerialize functions to provide custom deserialization and serialization logic. The MyJsonType object is then serialized to a JSON object and deserialized back from the JSON object. Note that the example uses the CJsonObject class from the IO namespace for JSON object manipulation.
|
inlineexplicitprotected |
Constructs an IJsonType object with the specified JSON field name.
| i_oFieldName | The name of the JSON field. |
|
inlineprotected |
Checks if serialization of the object is allowed and handles null fields.
| i_oObject | The JSON object being serialized to. |
| i_bIsStrict | Determines if strict serialization rules should be applied. |
|
inline |
Deserializes the object from a JSON object.
| i_oObject | The JSON object containing the serialized data. |
| i_bIsStrict | Determines if strict deserialization rules should be applied. |
|
inline |
Serializes the object to a JSON object.
| i_oObject | The JSON object to populate with serialized data. |
| i_bIsStrict | Determines if strict serialization rules should be applied. |
|
inlineprotected |
Retrieves the JSON object for the specified JSON field.
| i_oObject | The JSON object to search within. |
| i_bIsStrict | Determines if strict deserialization rules should be applied. |
|
inlineprotected |
Checks if the JSON field is null.
|
inlineprotected |
Retrieves the name of the JSON field.
|
inlineprotectedvirtual |
Called during deserialization to populate the object from a JSON object (non-strict mode).
| i_oObject | The JSON object containing the serialized data. |
|
inlineprotectedvirtual |
Called during deserialization to populate the object from a JSON object.
| i_oObject | The JSON object containing the serialized data. |
| i_bIsStrict | Determines if strict deserialization rules should be applied. |
|
inlineprotectedvirtual |
Called during deserialization to populate the object from a JSON object (non-strict mode).
| i_oObject | The JSON object containing the serialized data. |
|
inlineprotectedvirtual |
Called during serialization to convert the object to a JSON object.
| i_oObject | The JSON object to populate with serialized data. |
| i_bIsStrict | Determines if strict serialization rules should be applied. |
|
inline |
Assigns a JSON field name to the object.
| TJsonFieldName | The type of the JSON field name (CJsonFieldName). |
| i_tValue | The JSON field name to assign. |
IJsonType object.
|
inline |
Assigns a JSON field name to the object (move assignment).
| TJsonFieldName | The type of the JSON field name (CJsonFieldName). |
| i_tValue | The JSON field name to assign. |
IJsonType object.
|
inlineprotected |
Serializes the data to a JSON object.
This function serializes the data to a JSON object represented by the CJsonObject class. If the object already contains a field with the same name as this data object, the existing value is overwritten.
| i_oObject | The JSON object to serialize to. |
| i_bIsStrict | Flag indicating whether strict serialization should be performed. If set to true, only fields marked for serialization will be included in the output. If set to false, all fields will be included in the output. |
|
inlineprotected |
Sets the null state of the JSON field.
| i_bState | The null state to set. |
|
inlineoverridevirtual |
Retrieves the size of the object.
Reimplemented from Devel::Serializing::IData< int >.