Static Public Member Functions | |
static const picojson::value & | GetValue (const picojson::object &obj, std::string key) |
Returns the key from json object obj as a json value, throws error if key doesn't exist. More... | |
static const picojson::object & | GetObject (const picojson::object &obj, std::string key) |
Returns the key from json object obj as a json object, throws error if key doesn't exist. | |
static const picojson::array & | GetArray (const picojson::object &obj, std::string key) |
Returns the key from json object obj as a json array, will throw an error if key doesn't exist. | |
static std::string | GetString (const picojson::object &obj, std::string key) |
Returns the key from json object obj as a string, will throw an error if key doesn't exist. | |
static double | GetDouble (const picojson::object &obj, std::string key) |
Returns the key from json object obj as a double, will throw an error if key doesn't exist. | |
static std::vector< float > | GetStdFloatVector (const picojson::object &obj, std::string key) |
Returns the key from json object obj as a float vector, will throw an error if key doesn't exist. | |
static bool | ContainsKey (const picojson::object &obj, std::string key) |
Returns a boolean value of whether the json object obj contains key or not. | |
static picojson::object | CreateJsonNotification () |
Create a new json object for sending notifications. | |
static picojson::object | CreateJsonObject () |
Returns a new json object. | |
static picojson::value | ConvertPicojsonObjectToValue (picojson::object &obj) |
Converts given obj to an equivalent picojson::value. | |
static void | AddValueToJsonObject (picojson::object &obj, std::string key, picojson::value val) |
Adds a picojson value to the specifiied key in a json object. | |
static void | AddObjectToJsonObject (picojson::object &obj, std::string key, picojson::object &val) |
Adds the latter picojson object to the former object as a value under the key 'key'. | |
static void | AddStringToJsonObject (picojson::object &obj, std::string key, std::string val) |
Adds a string value named key to a json object. | |
static void | AddFloatToJsonObject (picojson::object &obj, std::string key, float num) |
Adds a float value named key to a json object. | |
static void | AddStdFloatVectorToJsonObject (picojson::object &obj, std::string key, std::vector< float > vec) |
Adds a float vector value named key to a json object. | |
static picojson::array | CreateJsonArrayFromVector (std::vector< float > vec) |
Creates a json array from a float vector. | |
static void | AddStdVectorVectorFloatToJsonObject (picojson::object &obj, std::string key, std::vector< std::vector< float >> array) |
Given a picojson object, key, and vector<vector<float>> array, adds the array as the value for key in obj. | |
static picojson::value | EncodeArray (const vector< vector< float >> arr) |
Given a vector<vector<float>> array, returns the array as a picojson::value. | |
static void | PrintArray (const picojson::array &arr) |
Helper method for PrintEntityDetails. | |
static void | PrintKeyValues (const picojson::object &obj, std::string prefix=" ") |
Helper method for PrintEntityDetails. | |
static void | Print (const picojson::object &obj, std::string prefix=" ") |
Helper method for PrintEntityDetails. | |
static void | PrintEntityDetails (const picojson::object &val) |
Prints the details of a json object representation of an entity. | |
|
inlinestatic |
Returns the key from json object obj as a json value, throws error if key doesn't exist.
USAGE: Use these querying methods to retrieve entity details from a json object. Look at project/web/scenes/umn.json lines 5-18 for an example of how an entity is represeted in a json object, or use JsonHelper::PrintEntityDetails(const picojson::object& val) to print the object's contents to the terminal.
Examples:
vector<float> position = JsonHelper::GetStdFloatVector(val, "position");
string type = JsonHelper::GetString(val, "type");