LPCGame
A Simple 2d Game Engine
|
A simple wrapper around JSON file reading and writing functionality. More...
#include <jsonhandler.h>
Public Member Functions | |
JsonHandler (const std::string file) | |
Json::Value | Read () const |
void | Write (const Json::Value &data) const |
void | SetFile (const std::string file) |
Set the filename to file. | |
std::string | File () const |
Get the filename. | |
A simple wrapper around JSON file reading and writing functionality.
Acts to simplify JSON file reading and writing tasks
JsonHandler::JsonHandler | ( | const std::string | file | ) |
Construct the JsonHandler and give it a filename to work with if the filename doesn't end in .json it will be assumed a config json file exists under the same path & name with the .json extension
file | The filename the JsonHandler is to read/write too |
Json::Value JsonHandler::Read | ( | ) | const |
Read JSON formatted data from mFile and return it
runtime_error | File to find if file not found |
runtime_error | Failed to parse if file couldn't be parsed as JSON |
void JsonHandler::Write | ( | const Json::Value & | data | ) | const |
Write data from a Json::Value to a JSON formatted file named mFile
data | The Json::Value of data to write |