GoPxL SDK
GoPxLSdk::GoJson Class Reference

Description

Simplify working with json data.

Public Member Functions

template<typename T >
void Add (const std::string &path, const T &val)
 Adds value if not exists. More...
 
template<std::size_t N>
void Add (const std::string &path, const char(&val)[N])
 Adds value if not exists. More...
 
GoJson At (int index)
 Gets object using pointer. More...
 
const GoJson At (int index) const
 Gets object using pointer. More...
 
GoJson At (const std::string &path)
 Gets object using pointer. More...
 
const GoJson At (const std::string &path) const
 Gets object using pointer. More...
 
GoJson At (const GoJsonPointer &pointer)
 Gets object using pointer. More...
 
const GoJson At (const GoJsonPointer &pointer) const
 Gets object using pointer. More...
 
GoJsonIterator Begin ()
 Gets an iterator to the first element. More...
 
const GoJsonIterator Begin () const
 Gets an iterator to the first element. More...
 
const bool Contains (const GoJsonPointer &pointer) const
 Checks if Json contains data. More...
 
void Copy (const std::string &source, const std::string &destination)
 Copies JSON object. More...
 
const bool Empty () const
 Checks if GoJson object is empty. More...
 
const GoJsonIterator End () const
 Gets an iterator to the last element. More...
 
GoJsonIterator Find (const std::string &key)
 Finds key in object. More...
 
GoJsonIterator Find (const GoJsonPointer &pointer)
 UNSUPPORTED! Finds key in object. More...
 
const GoJsonIterator Find (const std::string &key) const
 Finds key in object. More...
 
const GoJsonIterator Find (const GoJsonPointer &pointer) const
 UNSUPPORTED! Finds key in object. More...
 
void Flatten ()
 Flattens json. More...
 
template<typename T >
Get (const std::string &path)
 Gets value. More...
 
template<typename T >
Get ()
 Gets value. More...
 
template<typename T >
const T Get (const std::string &path) const
 Gets value. More...
 
template<typename T >
Get (const GoJsonPointer &pointer)
 Gets value. More...
 
template<typename T >
const T Get (const GoJsonPointer &pointer) const
 Gets value. More...
 
template<typename T >
const T Get () const
 Gets value. More...
 
ByteArray GetBinary ()
 Gets binary value. More...
 
 GoJson ()
 Creates empty GoJson object. More...
 
 GoJson (std::shared_ptr< nlohmann::json > json)
 Creates GoJson object based on nlohmann::json. More...
 
 GoJson (const GoJson &json)
 Copy constructor. More...
 
 GoJson (const std::string &data)
 Creates GoJson object. More...
 
bool HasKey (const std::string &key) const
 Checks if object contains key. More...
 
const bool IsArray () const
 Checks if GoJson is an array. More...
 
const bool IsArray (const std::string &path) const
 Checks if GoJson is an array. More...
 
const bool IsBinary () const
 Checks if GoJson is binary. More...
 
const bool IsBinary (const std::string &path) const
 Checks if GoJson is binary. More...
 
const bool IsBoolean () const
 Checks if GoJson is boolean. More...
 
const bool IsBoolean (const std::string &path) const
 Checks if GoJson is boolean. More...
 
const bool IsDiscarded () const
 Checks if GoJson value was discarded during parsing. More...
 
const bool IsDiscarded (const std::string &path) const
 Checks if GoJson value was discarded during parsing. More...
 
const bool IsFloat () const
 Checks if GoJson is float. More...
 
const bool IsFloat (const std::string &path) const
 Checks if GoJson is float. More...
 
const bool IsInteger () const
 Checks if GoJson is integer. More...
 
const bool IsInteger (const std::string &path) const
 Checks if GoJson is integer. More...
 
const bool IsNull () const
 Checks if GoJson is null. More...
 
const bool IsNull (const std::string &path) const
 Checks if GoJson is null. More...
 
const bool IsNumber () const
 Checks if GoJson is any number. More...
 
const bool IsNumber (const std::string &path) const
 Checks if GoJson is any number. More...
 
const bool IsObject () const
 Checks if GoJson is an object. More...
 
const bool IsObject (const std::string &path) const
 Checks if GoJson is an object. More...
 
const bool IsPrimitive () const
 Checks if GoJson is a primitive type. More...
 
const bool IsPrimitive (const std::string &path) const
 Checks if GoJson is a primitive type. More...
 
const bool IsString () const
 Checks if GoJson is the string. More...
 
const bool IsString (const std::string &path) const
 Checks if GoJson is the string. More...
 
const bool IsStructured () const
 Checks if GoJson is structured (array or object). More...
 
const bool IsStructured (const std::string &path) const
 Checks if GoJson is structured (array or object). More...
 
const bool IsUnsigned () const
 Checks if GoJson is unsigned. More...
 
const bool IsUnsigned (const std::string &path) const
 Checks if GoJson is unsigned. More...
 
void Merge (const GoJson &obj)
 Merges JSON object. More...
 
void Move (const std::string &source, const std::string &destination)
 Moves JSON object. More...
 
template<typename T >
void operator= (const T &left)
 
template<std::size_t N>
void operator= (const char(&val)[N])
 
static GoJson ParseMsgPack (const ByteArray &data)
 Parses JSON binary data. More...
 
static GoJson ParseString (const std::string &data)
 Parses JSON string data. More...
 
void Patch (const GoJson &obj)
 Patches JSON object. More...
 
void Remove (const std::string &path)
 Removes JSON object. More...
 
template<typename T >
void Replace (const std::string &path, const T &val)
 Replaces value. More...
 
template<std::size_t N>
void Replace (const std::string &path, const char(&val)[N])
 Adds value if not exists. More...
 
template<typename T >
void Set (const std::string &path, const T &val)
 Sets value. More...
 
template<std::size_t N>
void Set (const std::string &path, const char(&val)[N])
 Sets value. More...
 
template<typename T >
void Set (const GoJsonPointer &ptr, const T &val)
 Sets value. More...
 
template<std::size_t N>
void Set (const GoJsonPointer &ptr, const char(&val)[N])
 Sets value. More...
 
void Set (const std::string &path, const GoJson &val)
 Sets value. More...
 
void Set (const GoJsonPointer &ptr, const GoJson &val)
 Sets value. More...
 
void Set (const std::string &path, const std::vector< k8u > &val)
 Sets value. More...
 
void Set (const GoJsonPointer &ptr, const std::vector< k8u > &val)
 Sets value. More...
 
const size_t Size () const
 Gets size of the array. More...
 
const ByteArray ToBinary ()
 Gets JSON as a ByteArray. More...
 
const std::string ToString ()
 Gets string formatted JSON. More...
 
const std::string ToString () const
 Gets string formatted JSON. More...
 
void Unflatten ()
 Unflattens json. More...
 
 ~GoJson ()
 Destroys GoJson object. More...
 

Protected Member Functions

const std::shared_ptr
< nlohmann::json
GetHandle (const std::string &path) const
 Gets JSON handle at specific path. More...
 
const std::shared_ptr
< nlohmann::json > & 
GetHandle () const
 Gets handle to nlohmann::json. More...
 
std::shared_ptr< nlohmann::jsonGetHandle (const std::string &path)
 Gets JSON handle at specific path. More...
 
std::shared_ptr< nlohmann::json > & GetHandle ()
 Gets handle to nlohmann::json. More...
 

Friends

class GoJsonIterator
 
class GoRequest
 
std::ostream & operator<< (std::ostream &os, const GoJson &json)
 
template<typename T >
bool operator== (const GoJson &left, const T &right)
 
template<std::size_t N>
bool operator== (const GoJson &left, const char(&val)[N])
 

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