JSONObject Class Reference

The JSONObject class is used to represent and (de)serialize JSON objects. More...

#include <ArmarXCore/util/json/JSONObject.h>

+ Inheritance diagram for JSONObject:

Public Member Functions

void append (const armarx::AbstractObjectSerializerPtr &val) override
 
std::string asString (bool pretty=false) const
 
armarx::AbstractObjectSerializerPtr createElement () const override
 
void fromString (const ::std::string &jsonString, const ::Ice::Current &=Ice::emptyCurrent) override
 
template<typename T >
void getArray (const std::string &key, std::vector< T > &result)
 
bool getBool (const ::std::string &key) const override
 
double getDouble (const ::std::string &key) const override
 
void getDoubleArray (const ::std::string &key, std::vector< double > &result) override
 
armarx::AbstractObjectSerializerPtr getElement (const ::std::string &key) const override
 
armarx::AbstractObjectSerializerPtr getElement (unsigned int index) const override
 
std::vector< std::string > getElementNames () const override
 
armarx::ElementType getElementType (const ::Ice::Current &=Ice::emptyCurrent) const override
 
float getFloat (const ::std::string &key) const override
 
void getFloatArray (const ::std::string &key, std::vector< float > &result) override
 
int getInt (const ::std::string &key) const override
 
void getIntArray (const ::std::string &key, std::vector< int > &result) override
 
const Json::Value & getJsonValue () const
 
std::string getString (const ::std::string &key) const override
 
void getStringArray (const ::std::string &key, std::vector< std::string > &result) override
 
void getVariantArray (const ::std::string &key, std::vector< armarx::VariantPtr > &result) override
 
void getVariantMap (const ::std::string &key, armarx::StringVariantBaseMap &result) override
 
bool hasElement (const ::std::string &key) const override
 
 JSONObject (armarx::ElementType nodeType=armarx::ElementTypes::eObject, const Ice::CommunicatorPtr ic=Ice::CommunicatorPtr())
 
 JSONObject (const Ice::CommunicatorPtr ic)
 
 JSONObject (const JSONObject &toCopy)
 
void merge (const armarx::AbstractObjectSerializerPtr &val) override
 
void reset () override
 
template<typename T >
void set (const ::std::string &key, T val)
 
template<typename T >
void set (int index, T val)
 
template<typename T >
void setArray (const ::std::string &key, const std::vector< T > &val)
 
void setBool (const ::std::string &key, bool val) override
 
void setBool (unsigned int index, bool val) override
 
void setDouble (const ::std::string &key, double val) override
 
void setDouble (unsigned int index, double val) override
 
void setDoubleArray (const ::std::string &key, const std::vector< double > &val) override
 
void setElement (const ::std::string &key, const armarx::AbstractObjectSerializerPtr &obj) override
 
void setElement (unsigned int index, const armarx::AbstractObjectSerializerPtr &obj) override
 
void setElementType (armarx::ElementType nodeType, const ::Ice::Current &=Ice::emptyCurrent) override
 
void setFloat (const ::std::string &key, float val) override
 
void setFloat (unsigned int index, float val) override
 
void setFloatArray (const ::std::string &key, const std::vector< float > &val) override
 
void setInt (const ::std::string &key, int val) override
 
void setInt (unsigned int index, int val) override
 
void setIntArray (const ::std::string &key, const std::vector< int > &val) override
 
void setString (const ::std::string &key, const std::string &val) override
 
void setString (unsigned int index, const std::string &val) override
 
void setStringArray (const ::std::string &key, const std::vector< std::string > &val) override
 
void setVariantArray (const ::std::string &key, const std::vector< armarx::VariantBasePtr > &val) override
 
void setVariantArray (const ::std::string &key, const std::vector< armarx::VariantPtr > &val) override
 
void setVariantMap (const ::std::string &key, const armarx::StringVariantBaseMap &val) override
 
unsigned int size () const override
 
std::string toString (const ::Ice::Current &=Ice::emptyCurrent) const override
 
 ~JSONObject () override
 
- Public Member Functions inherited from AbstractObjectSerializer
 AbstractObjectSerializer ()
 
 AbstractObjectSerializer (const Ice::CommunicatorPtr ic)
 
SerializablePtr deserializeIceObject ()
 
virtual SerializablePtr getIceObject (const ::std::string &key) const
 
virtual SerializablePtr getIceObject (int index) const
 
std::string getIdField () const
 
int getIntId () const
 
std::string getStringId () const
 
virtual VariantPtr getVariant (const ::std::string &key) const
 
virtual VariantPtr getVariant (int index) const
 
void serializeIceObject (const SerializablePtr &obj)
 
void setIceCommunicator (Ice::CommunicatorPtr ic)
 
virtual void setIceObject (const ::std::string &key, const SerializablePtr &val)
 
virtual void setIceObject (unsigned int index, const SerializablePtr &val)
 
void setId (const std::string &val)
 
void setId (int val)
 
void setIdField (const std::string &fieldName)
 
virtual void setVariant (const ::std::string &key, const VariantPtr &val)
 
virtual void setVariant (unsigned int index, const VariantPtr &val)
 
 ~AbstractObjectSerializer () override
 

Static Public Member Functions

static StringVariantBaseMap ConvertToBasicVariantMap (const JSONObjectPtr &serializer, const VariantBasePtr &variant)
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractObjectSerializer
VariantPtr deserializeVariant ()
 
AbstractObjectSerializerPtr serializeVariant (const VariantPtr &val) const
 
- Protected Attributes inherited from AbstractObjectSerializer
Ice::CommunicatorPtr ic
 
std::string idField
 

Detailed Description

The JSONObject class is used to represent and (de)serialize JSON objects.

Accessing the object is not thread safe. (De)Serializing multiple JSON objects should be done with a new instance for each object.

Definition at line 43 of file JSONObject.h.

Constructor & Destructor Documentation

◆ JSONObject() [1/3]

Definition at line 34 of file JSONObject.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ JSONObject() [2/3]

Definition at line 40 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ JSONObject() [3/3]

JSONObject ( const JSONObject toCopy)

Definition at line 46 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ ~JSONObject()

~JSONObject ( )
override

Definition at line 54 of file JSONObject.cpp.

Member Function Documentation

◆ append()

void append ( const armarx::AbstractObjectSerializerPtr val)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 171 of file JSONObject.cpp.

◆ asString()

std::string asString ( bool  pretty = false) const

Definition at line 63 of file JSONObject.cpp.

+ Here is the caller graph for this function:

◆ ConvertToBasicVariantMap()

StringVariantBaseMap ConvertToBasicVariantMap ( const JSONObjectPtr serializer,
const VariantBasePtr variant 
)
static

Definition at line 523 of file JSONObject.cpp.

+ Here is the caller graph for this function:

◆ createElement()

armarx::AbstractObjectSerializerPtr createElement ( ) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 98 of file JSONObject.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromString()

void fromString ( const ::std::string &  jsonString,
const ::Ice::Current &  = Ice::emptyCurrent 
)
override

Definition at line 86 of file JSONObject.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArray()

void getArray ( const std::string &  key,
std::vector< T > &  result 
)
inline

Definition at line 73 of file JSONObject.h.

+ Here is the caller graph for this function:

◆ getBool()

bool getBool ( const ::std::string &  key) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 357 of file JSONObject.cpp.

◆ getDouble()

double getDouble ( const ::std::string &  key) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 321 of file JSONObject.cpp.

◆ getDoubleArray()

void getDoubleArray ( const ::std::string &  key,
std::vector< double > &  result 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 99 of file JSONObject.h.

+ Here is the call graph for this function:

◆ getElement() [1/2]

armarx::AbstractObjectSerializerPtr getElement ( const ::std::string &  key) const
overridevirtual

◆ getElement() [2/2]

armarx::AbstractObjectSerializerPtr getElement ( unsigned int  index) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 394 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ getElementNames()

std::vector< std::string > getElementNames ( ) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 430 of file JSONObject.cpp.

◆ getElementType()

armarx::ElementType getElementType ( const ::Ice::Current &  = Ice::emptyCurrent) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 483 of file JSONObject.cpp.

+ Here is the caller graph for this function:

◆ getFloat()

float getFloat ( const ::std::string &  key) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 303 of file JSONObject.cpp.

◆ getFloatArray()

void getFloatArray ( const ::std::string &  key,
std::vector< float > &  result 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 95 of file JSONObject.h.

+ Here is the call graph for this function:

◆ getInt()

int getInt ( const ::std::string &  key) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 339 of file JSONObject.cpp.

◆ getIntArray()

void getIntArray ( const ::std::string &  key,
std::vector< int > &  result 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 91 of file JSONObject.h.

+ Here is the call graph for this function:

◆ getJsonValue()

const Json::Value & getJsonValue ( ) const

Definition at line 93 of file JSONObject.cpp.

+ Here is the caller graph for this function:

◆ getString()

std::string getString ( const ::std::string &  key) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 375 of file JSONObject.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStringArray()

void getStringArray ( const ::std::string &  key,
std::vector< std::string > &  result 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 103 of file JSONObject.h.

+ Here is the call graph for this function:

◆ getVariantArray()

void getVariantArray ( const ::std::string &  key,
std::vector< armarx::VariantPtr > &  result 
)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 442 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ getVariantMap()

void getVariantMap ( const ::std::string &  key,
armarx::StringVariantBaseMap result 
)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 463 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ hasElement()

bool hasElement ( const ::std::string &  key) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 207 of file JSONObject.cpp.

◆ merge()

void merge ( const armarx::AbstractObjectSerializerPtr val)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 185 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ reset()

void reset ( )
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 518 of file JSONObject.cpp.

◆ set() [1/2]

void set ( const ::std::string &  key,
T  val 
)
inline

Definition at line 111 of file JSONObject.h.

+ Here is the caller graph for this function:

◆ set() [2/2]

void set ( int  index,
T  val 
)
inline

Definition at line 117 of file JSONObject.h.

◆ setArray()

void setArray ( const ::std::string &  key,
const std::vector< T > &  val 
)
inline

Definition at line 123 of file JSONObject.h.

+ Here is the caller graph for this function:

◆ setBool() [1/2]

void setBool ( const ::std::string &  key,
bool  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 140 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setBool() [2/2]

void setBool ( unsigned int  index,
bool  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 182 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setDouble() [1/2]

void setDouble ( const ::std::string &  key,
double  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 152 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setDouble() [2/2]

void setDouble ( unsigned int  index,
double  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 194 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setDoubleArray()

void setDoubleArray ( const ::std::string &  key,
const std::vector< double > &  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 170 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setElement() [1/2]

void setElement ( const ::std::string &  key,
const armarx::AbstractObjectSerializerPtr obj 
)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 104 of file JSONObject.cpp.

◆ setElement() [2/2]

void setElement ( unsigned int  index,
const armarx::AbstractObjectSerializerPtr obj 
)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 165 of file JSONObject.cpp.

◆ setElementType()

void setElementType ( armarx::ElementType  nodeType,
const ::Ice::Current &  = Ice::emptyCurrent 
)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 499 of file JSONObject.cpp.

+ Here is the caller graph for this function:

◆ setFloat() [1/2]

void setFloat ( const ::std::string &  key,
float  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 148 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setFloat() [2/2]

void setFloat ( unsigned int  index,
float  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 190 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setFloatArray()

void setFloatArray ( const ::std::string &  key,
const std::vector< float > &  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 166 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setInt() [1/2]

void setInt ( const ::std::string &  key,
int  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 144 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setInt() [2/2]

void setInt ( unsigned int  index,
int  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 186 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setIntArray()

void setIntArray ( const ::std::string &  key,
const std::vector< int > &  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 162 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setString() [1/2]

void setString ( const ::std::string &  key,
const std::string &  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 156 of file JSONObject.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setString() [2/2]

void setString ( unsigned int  index,
const std::string &  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 198 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setStringArray()

void setStringArray ( const ::std::string &  key,
const std::vector< std::string > &  val 
)
inlineoverridevirtual

Implements AbstractObjectSerializer.

Definition at line 174 of file JSONObject.h.

+ Here is the call graph for this function:

◆ setVariantArray() [1/2]

void setVariantArray ( const ::std::string &  key,
const std::vector< armarx::VariantBasePtr > &  val 
)
overridevirtual

◆ setVariantArray() [2/2]

void setVariantArray ( const ::std::string &  key,
const std::vector< armarx::VariantPtr > &  val 
)
overridevirtual

◆ setVariantMap()

void setVariantMap ( const ::std::string &  key,
const armarx::StringVariantBaseMap val 
)
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 143 of file JSONObject.cpp.

+ Here is the call graph for this function:

◆ size()

unsigned int size ( ) const
overridevirtual

Implements AbstractObjectSerializer.

Definition at line 202 of file JSONObject.cpp.

◆ toString()

std::string toString ( const ::Ice::Current &  = Ice::emptyCurrent) const
override

Definition at line 58 of file JSONObject.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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