utility class to help managing typical operations on json files. (loading, manipulating, writing) More...
#include <JsonJig.h>
Public Types | |
enum | Mode { WRITE, READ } |
this enum helps to determine the performed operation wheter the file is going to ber read or written More... | |
enum | Format { COMPACT, PRETTY } |
enumeration that defines the format the json is going to be written, either if it's minified/compact and request volumn friends or pretty and easily readable for humans More... | |
Public Member Functions | |
JsonJig () | |
constructs a plain object ready to have values added | |
JsonJig (const char *path) | |
initially reads the json files contents from the provided path and creates a iyf::JsonJig object for manipulation of this json More... | |
~JsonJig () | |
properly cleans up | |
bool | readFromFile (const char *path) |
reads a jsonfiles contents More... | |
bool | readFromString (const std::string &json) |
creates a iyf::JsonJig file from an input string instead from a file read from disk More... | |
bool | writeToFile (const char *path) |
writes the currently stored json structure to a file More... | |
bool | writeToFile (const char *path, Format format) |
write to file and specify the format PRETTY, COMPACT it is going to be written in More... | |
Json::Value & | getRoot () |
returns the root node of the json structure currently stored More... | |
Json::Value & | getValue (const char *path) |
traverses the json and trys to find the Json::Value at the specified path More... | |
Json::Value & | getValue (const char *path, Json::Value &startRef) |
traverses down a json structure from a certain start point onwards More... | |
void | setValue (const char *path, Json::Value &val) |
stets a json Value at a certain position More... | |
utility class to help managing typical operations on json files. (loading, manipulating, writing)
this class is a convenience wrapper around JsonCpp to help setting values at a certain path to take the hastle of manually stepping down the json hierarchy.
enum iyf::JsonJig::Format |
enum iyf::JsonJig::Mode |
this enum helps to determine the performed operation wheter the file is going to ber read or written
Enumerator | |
---|---|
WRITE |
the file processed by iyf::JsonJig is going to be written |
READ |
the file processed by iyf::JsonJig is going to be read |
JsonJig::JsonJig | ( | const char * | path | ) |
initially reads the json files contents from the provided path and creates a iyf::JsonJig object for manipulation of this json
const | char* path the path to read the json file from |
Json::Value & JsonJig::getRoot | ( | ) |
returns the root node of the json structure currently stored
Json::Value & JsonJig::getValue | ( | const char * | path | ) |
traverses the json and trys to find the Json::Value at the specified path
const | char* path to the Json::Value in question |
Json::Value & JsonJig::getValue | ( | const char * | path, |
Json::Value & | startRef | ||
) |
traverses down a json structure from a certain start point onwards
const | char* path to the Json::Value in question |
Json::Value& | startRef the node to start traversal from |
bool JsonJig::readFromFile | ( | const char * | path | ) |
reads a jsonfiles contents
const | char* path the path to read the json file from |
bool JsonJig::readFromString | ( | const std::string & | json | ) |
creates a iyf::JsonJig file from an input string instead from a file read from disk
const | std::string &json the json string to be converted into a JsonCpp object tree |
void JsonJig::setValue | ( | const char * | path, |
Json::Value & | val | ||
) |
stets a json Value at a certain position
const | char* path to the destination of the value |
Json::Value | &val to be set at the position path points to |
bool JsonJig::writeToFile | ( | const char * | path | ) |
writes the currently stored json structure to a file
const | char* path the json is going to be saved to |
bool JsonJig::writeToFile | ( | const char * | path, |
JsonJig::Format | format | ||
) |
write to file and specify the format PRETTY, COMPACT it is going to be written in
const | char* path the json is going to be saved to |
Format | format the file is going to be saved in (PRETTY/COMPACT) |