softwarecontainer
0.18.0-739e8d7 2017-05-04
|
Convenience layer for the Jansson JSON parser. More...
#include <jsonparser.h>
Static Public Member Functions | |
static bool | readOptional (const json_t *element, const char *key, std::string &result) |
Reads an optional value from a JSON object. More... | |
static bool | readOptional (const json_t *element, const char *key, bool &result) |
static bool | readOptional (const json_t *element, const char *key, int &result) |
static bool | read (const json_t *element, const char *key, std::string &result) |
Reads a string from a JSON Object. More... | |
static bool | read (const json_t *element, const char *key, bool &result) |
Reads a boolean from a JSON Object. More... | |
static bool | read (const json_t *element, const char *key, int &result) |
Reads an integer from a JSON Object. More... | |
static bool | hasKey (const json_t *element, const char *key) |
Checks if a given JSON object contains a certain key. More... | |
Convenience layer for the Jansson JSON parser.
This class provides convenience functions that handles commonly used operations using the Janssson JSON parser.
Definition at line 32 of file jsonparser.h.
|
static |
Reads an optional value from a JSON object.
This differs from the read functions in that it return true instead of false if the key was not found, so the only way it returns false is if the key was of bad type or could not be parsed (but existed)
Definition at line 24 of file jsonparser.cpp.
References hasKey(), and read().
|
static |
Reads a string from a JSON Object.
Tries to read a string value form a given JSON object using a given key. If the read is successful true will be returned and the result reference will be populated with the read value. If the string could not be read, either due to the given object does not contain the given key or the given key did not hold a string, false will be returned and the result reference will not be changed.
Definition at line 51 of file jsonparser.cpp.
Referenced by softwarecontainer::BaseConfigStore::BaseConfigStore(), softwarecontainer::Device::parse(), softwarecontainer::NetworkGatewayParser::parseNetworkGatewayConfiguration(), softwarecontainer::WaylandGateway::readConfigElement(), softwarecontainer::PulseGateway::readConfigElement(), and readOptional().
|
static |
Reads a boolean from a JSON Object.
Tries to read a boolean value form a given JSON object using a given key. If the read is successful true will be returned and the result reference will be populated with the read value. If the boolean could not be read, either due to the given object does not contain the given key or the given key did not hold a boolean value, false will be returned and the result reference will not be changed.
Definition at line 68 of file jsonparser.cpp.
|
static |
Reads an integer from a JSON Object.
Tries to read an integer value form a given JSON object using a given key. If the read is successful true will be returned and the result reference will be populated with the read value. If the integer could not be read, either due to the given object does not contain the given key or the given key did not hold an integer value, false will be returned and the result reference will not be changed.
Definition at line 85 of file jsonparser.cpp.
|
static |
Checks if a given JSON object contains a certain key.
Definition at line 102 of file jsonparser.cpp.
Referenced by readOptional().