#include <json.h>
Public Member Functions | |
| vector< string > | getKeys () |
| bool | hasKey (const string &key) |
| bool | isArray (const string &key) |
| unsigned | getArrayLength (const string &arrayKey) |
| bool | isNull (const string &key) |
| string | getRequiredStringValue (const string &key, bool allowEmpty=false) |
| optional< int > | getIntValue (const string &key) |
| int | getRequiredIntValue (const string &key) |
| optional< unsigned long long > | getUnsignedLongValue (const string &key) |
| unsigned long long | getRequiredUnsignedLongValue (const string &key) |
| optional< bool > | getBooleanValue (const string &key) |
| bool | getRequiredBooleanValue (const string &key) |
| optional< double > | getDoubleValue (const string &key) |
| double | getRequiredDoubleValue (const string &key) |
| optional< float > | getFloatValue (const string &key) |
| float | getRequiredFloatValue (const string &key) |
| optional< string > | getStringValue (const string &key) |
| CscJsonObjectReader | getRequiredObjectValue (const string &key) |
| optional< CscJsonObjectReader > | getObjectValue (const string &key) |
| CscJsonObjectReader * | getRequiredObjectPtrValue (const string &key) |
| optional< CscJsonObjectReader * > | getObjectPtrValue (const string &key) |
| ptr< CscJsonObjectReader > | getRequiredObjectSharedPtrValue (const string &key) |
| optional< ptr< CscJsonObjectReader > > | getObjectSharedPtrValue (const string &key) |
| map< string, optional< any > > | getRequiredObjectValueAsMap (const string &key) |
| map< string, string > | getRequiredObjectValueAsMapOfStrings (const string &key) |
| optional< map< string, optional< any > > > | getObjectValueAsMap (const string &key) |
| optional< any > | getAnyValue (string key) |
| template<class T > | |
| vector< T > | getRequiredArrayValue (const string &key) |
| template<class T > | |
| optional< vector< T > > | getArrayValue (const string &key) |
| template<class T > | |
| optional< T > | getArrayItemValue (const string &arrayKey, size_t index) |
| template<class T > | |
| T | getRequiredArrayItemValue (const string &arrayKey, size_t index) |
| template<class T > | |
| vector< T > | asArrayValue () |
| CscJsonObjectReader (ptr< yyjson_doc > yyjsonDoc, yyjson_val *yyjsonValue=nullptr, bool doNotReleaseYyjsonObjects=false) | |
| CscJsonObjectReader (const fs::path filePath) | |
| CscJsonObjectReader (const string &jsonContent) | |
| virtual | ~CscJsonObjectReader () |
| string | toString () |
| string | toJsonString (bool prettyPrint=false) |
| CscJsonObject * | toMutable (yyjson_mut_doc *parentDoc=nullptr) |
| yyjson_val * | getLowLevelParser () |
Static Public Member Functions | |
| static vector< CscJsonObject * > | toMutableList (const vector< ptr< CscJsonObjectReader >> values) |
Protected Member Functions | |
| virtual ptr< yyjson_doc > | getYyjsonDoc () |
| virtual yyjson_val * | getYyjsonValue () |
| yyjson_val * | getValueByPropertyPath (const string &propertyPath) |
Static Protected Member Functions | |
| static ptr< yyjson_doc > | createYyjsonSharedPtr (yyjson_doc *doc) |
| static yyjson_doc * | parseFromFile (const fs::path filePath) |
| static yyjson_doc * | parseFromString (const string &jsonString) |
Protected Attributes | |
| ptr< yyjson_doc > | yyjsonDoc = nullptr |
| yyjson_val * | yyjsonValue = nullptr |
| conscience_utils::JSON::CscJsonObjectReader::CscJsonObjectReader | ( | ptr< yyjson_doc > | yyjsonDoc, |
| yyjson_val * | yyjsonValue = nullptr, |
||
| bool | doNotReleaseYyjsonObjects = false |
||
| ) |
| yyjsonDoc | currently read doc, yyjson type. nullptr can be passed by subclass for editing purpose for instance |
| yyjsonValue | the value connected to this reader object. The reader will read from this value. |
| conscience_utils::JSON::CscJsonObjectReader::CscJsonObjectReader | ( | const fs::path | filePath | ) |
| conscience_utils::JSON::CscJsonObjectReader::CscJsonObjectReader | ( | const string & | jsonContent | ) |
|
virtual |
|
inline |
valid types for T: double, int, uint, string , CscJsonObjectReader* or ptr<CscJsonObjectReader>
|
staticprotected |
| optional< any > conscience_utils::JSON::CscJsonObjectReader::getAnyValue | ( | string | key | ) |
gets optional any value
|
inline |
valid types for T: double, int, uint, string , CscJsonObjectReader* or ptr<CscJsonObjectReader>
| unsigned conscience_utils::JSON::CscJsonObjectReader::getArrayLength | ( | const string & | arrayKey | ) |
returns length if array property exists at property path (can be separated by '.' to access nested props), otherwise throws MissingRequiredPropertyException
|
inline |
valid types for T: double, int, uint, string , CscJsonObjectReader* or ptr<CscJsonObjectReader>
| optional< bool > conscience_utils::JSON::CscJsonObjectReader::getBooleanValue | ( | const string & | key | ) |
| optional< double > conscience_utils::JSON::CscJsonObjectReader::getDoubleValue | ( | const string & | key | ) |
gets optional double value
| optional< float > conscience_utils::JSON::CscJsonObjectReader::getFloatValue | ( | const string & | key | ) |
gets optional double value
| optional< int > conscience_utils::JSON::CscJsonObjectReader::getIntValue | ( | const string & | key | ) |
gets optional int value
| vector< string > conscience_utils::JSON::CscJsonObjectReader::getKeys | ( | ) |
| yyjson_val * conscience_utils::JSON::CscJsonObjectReader::getLowLevelParser | ( | ) |
sometimes it can be useful to work with raw values to avoid conversions
| optional< CscJsonObjectReader * > conscience_utils::JSON::CscJsonObjectReader::getObjectPtrValue | ( | const string & | key | ) |
gets optional object value, you need to delete it
| optional< ptr< CscJsonObjectReader > > conscience_utils::JSON::CscJsonObjectReader::getObjectSharedPtrValue | ( | const string & | key | ) |
gets optional object value
| optional< CscJsonObjectReader > conscience_utils::JSON::CscJsonObjectReader::getObjectValue | ( | const string & | key | ) |
gets optional object value
| optional< map< string, optional< any > > > conscience_utils::JSON::CscJsonObjectReader::getObjectValueAsMap | ( | const string & | key | ) |
gets optional object value as map
|
inline |
valid types for T: double, int, uint, string , CscJsonObjectReader* or ptr<CscJsonObjectReader>
|
inline |
valid types for T: double, int, uint, string , CscJsonObjectReader* or ptr<CscJsonObjectReader>
| bool conscience_utils::JSON::CscJsonObjectReader::getRequiredBooleanValue | ( | const string & | key | ) |
| double conscience_utils::JSON::CscJsonObjectReader::getRequiredDoubleValue | ( | const string & | key | ) |
gets double value, or throw error
| float conscience_utils::JSON::CscJsonObjectReader::getRequiredFloatValue | ( | const string & | key | ) |
gets double value, or throw error
| int conscience_utils::JSON::CscJsonObjectReader::getRequiredIntValue | ( | const string & | key | ) |
gets int value, or throw error
| CscJsonObjectReader * conscience_utils::JSON::CscJsonObjectReader::getRequiredObjectPtrValue | ( | const string & | key | ) |
gets object value, or throw error, you need to delete it
| ptr< CscJsonObjectReader > conscience_utils::JSON::CscJsonObjectReader::getRequiredObjectSharedPtrValue | ( | const string & | key | ) |
gets object value, or throw error
| CscJsonObjectReader conscience_utils::JSON::CscJsonObjectReader::getRequiredObjectValue | ( | const string & | key | ) |
gets object value, or throw error
| map< string, optional< any > > conscience_utils::JSON::CscJsonObjectReader::getRequiredObjectValueAsMap | ( | const string & | key | ) |
gets object value as map, or throws error
| map< string, string > conscience_utils::JSON::CscJsonObjectReader::getRequiredObjectValueAsMapOfStrings | ( | const string & | key | ) |
gets object value as map of strings, or throws error
| string conscience_utils::JSON::CscJsonObjectReader::getRequiredStringValue | ( | const string & | key, |
| bool | allowEmpty = false |
||
| ) |
gets string value, or throw error
| unsigned long long conscience_utils::JSON::CscJsonObjectReader::getRequiredUnsignedLongValue | ( | const string & | key | ) |
gets unsigned long long value, or throw error
| optional< string > conscience_utils::JSON::CscJsonObjectReader::getStringValue | ( | const string & | key | ) |
gets optional string value
| optional< unsigned long long > conscience_utils::JSON::CscJsonObjectReader::getUnsignedLongValue | ( | const string & | key | ) |
gets optional unsigned long long value
|
protected |
|
protectedvirtual |
Reimplemented in conscience_utils::JSON::CscJsonObject.
|
protectedvirtual |
Reimplemented in conscience_utils::JSON::CscJsonObject.
| bool conscience_utils::JSON::CscJsonObjectReader::hasKey | ( | const string & | key | ) |
returns true if property exists from property path (can be separated by '.' to access nested props)
| bool conscience_utils::JSON::CscJsonObjectReader::isArray | ( | const string & | key | ) |
returns true if property exists at property path (can be separated by '.' to access nested props) and is an array
| bool conscience_utils::JSON::CscJsonObjectReader::isNull | ( | const string & | key | ) |
returns true if property value at given key is either absent, null, or unknown type
|
staticprotected |
|
staticprotected |
| string conscience_utils::JSON::CscJsonObjectReader::toJsonString | ( | bool | prettyPrint = false | ) |
| CscJsonObject * conscience_utils::JSON::CscJsonObjectReader::toMutable | ( | yyjson_mut_doc * | parentDoc = nullptr | ) |
| parentDoc | important if your value must be attached to another json object root. If null -> a new detached json doc will be created |
|
static |
| string conscience_utils::JSON::CscJsonObjectReader::toString | ( | ) |
|
protected |
|
protected |