10Duke Scale C++ Client
Loading...
Searching...
No Matches
JSONElement Class Referenceabstract

#include <JSONElement.h>

Detailed Description

Superclass of JSON elements.

Inheritance diagram for JSONElement:
tenduke::json::JSONArray tenduke::json::JSONBoolean tenduke::json::JSONNumber tenduke::json::JSONObject tenduke::json::JSONString tenduke::test::mocks::JSONElementMock tenduke::test::mocks::JSONArrayMock tenduke::test::mocks::JSONBooleanMock tenduke::test::mocks::JSONNumberMock tenduke::test::mocks::JSONObjectMock tenduke::test::mocks::JSONStringMock

Public Types

enum  Type {
  UNDEFINED , NULLISH , OBJECT , ARRAY ,
  NUMBER , STRING , BOOLEAN
}
 Type of the element.
 

Public Member Functions

virtual enum Type getType () const=0
 Returns type of this element.
 
virtual std::string asJSON () const=0
 Serializes the element as JSON.
 
virtual std::string asString () const=0
 Gets the value of the element as a string.
 
bool isArray () const
 Utility to check if this element is JSONArray.
 
bool isBoolean () const
 Utility to check if this element is JSONBoolean.
 
bool isNull () const
 Utility to check if this element is null.
 
bool isNumber () const
 Utility to check if this element is JSONNumber.
 
bool isObject () const
 Utility to check if this element is JSONObject.
 
bool isString () const
 Utility to check if this element is JSONString.
 
bool isUndefined () const
 Utility to check if this element is undefined.
 

Static Public Member Functions

static std::string typeToString (const enum Type type)
 Converts the type to string.
 

Member Function Documentation

◆ asJSON()

virtual std::string tenduke::json::JSONElement::asJSON ( ) const
pure virtual

Serializes the element as JSON.

Returns
- JSON representation of this element

◆ asString()

virtual std::string tenduke::json::JSONElement::asString ( ) const
pure virtual

Gets the value of the element as a string.

This does not serialize the value as JSON, but just converts the actual value to string. Exceptions are tenduke::json::JSONArray and tenduke::json::JSONObject which return serialized value.

Returns
- String representation of this element

◆ getType()

virtual enum Type tenduke::json::JSONElement::getType ( ) const
pure virtual

Returns type of this element.

Returns
-

◆ isArray()

bool tenduke::json::JSONElement::isArray ( ) const
inline

Utility to check if this element is JSONArray.

Returns
-

◆ isBoolean()

bool tenduke::json::JSONElement::isBoolean ( ) const
inline

Utility to check if this element is JSONBoolean.

Returns
-

◆ isNull()

bool tenduke::json::JSONElement::isNull ( ) const
inline

Utility to check if this element is null.

Returns
-

◆ isNumber()

bool tenduke::json::JSONElement::isNumber ( ) const
inline

Utility to check if this element is JSONNumber.

Returns
-

◆ isObject()

bool tenduke::json::JSONElement::isObject ( ) const
inline

Utility to check if this element is JSONObject.

Returns
-

◆ isString()

bool tenduke::json::JSONElement::isString ( ) const
inline

Utility to check if this element is JSONString.

Returns
-

◆ isUndefined()

bool tenduke::json::JSONElement::isUndefined ( ) const
inline

Utility to check if this element is undefined.

Returns
-

◆ typeToString()

static std::string tenduke::json::JSONElement::typeToString ( const enum Type type)
inlinestatic

Converts the type to string.

Parameters
type-
Returns
-

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