#ifndef JsonUtil_H #define JsonUtil_H class RageFileBasic; #include "jsoncpp/include/json/value.h" /** @brief Utilities for handling JSON data. */ namespace JsonUtil { bool LoadFromString( Json::Value &root, RString sData, RString &sErrorOut ); bool LoadFromStringShowErrors(Json::Value &root, const RString sData); bool LoadFromFileShowErrors(Json::Value &root, const RString &sFile); bool LoadFromFileShowErrors(Json::Value &root, RageFileBasic &f); bool WriteFile(const Json::Value &root, const RString &sFile, bool bMinified); template static void SerializeVectorObjects(const vector &v, void fn(const T &, Json::Value &), Json::Value &root) { root = Json::Value(Json::arrayValue); root.resize(v.size()); for(unsigned i=0; i static void SerializeVectorPointers(const vector &v, void fn(const T &, Json::Value &), Json::Value &root) { root = Json::Value(Json::arrayValue); root.resize(v.size()); for(unsigned i=0; i static void SerializeVectorValues(const vector &v, Json::Value &root) { root = Json::Value(Json::arrayValue); root.resize(v.size()); for(unsigned i=0; i static void DeserializeVectorObjects(vector &v, void fn(T &, const Json::Value &), const Json::Value &root) { v.resize(root.size()); for(unsigned i=0; i static void DeserializeVectorPointers(vector &v, void fn(T &, const Json::Value &), const Json::Value &root) { for(unsigned i=0; i static void DeserializeVectorValues(vector &v, const Json::Value &root) { v.resize(root.size()); for(unsigned i=0; i