Improved Json methods to correct work with swig and inheritance.

This commit is contained in:
Jonathan Thomas
2013-12-07 21:09:55 -06:00
parent e3d41808b9
commit cd7743fb88
44 changed files with 787 additions and 221 deletions

View File

@@ -29,13 +29,6 @@
using namespace openshot;
// Generate JSON string of this object
string ClipBase::Json() {
// Return formatted string
return JsonValue().toStyledString();
}
// Generate Json::JsonValue for this object
Json::Value ClipBase::JsonValue() {
@@ -50,31 +43,8 @@ Json::Value ClipBase::JsonValue() {
return root;
}
// Load JSON string into this object
void ClipBase::Json(string value) throw(InvalidJSON) {
// Parse JSON string into JSON objects
Json::Value root;
Json::Reader reader;
bool success = reader.parse( value, root );
if (!success)
// Raise exception
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
try
{
// Set all values that match
Json(root);
}
catch (exception e)
{
// Error parsing JSON (or missing keys)
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
}
}
// Load Json::JsonValue into this object
void ClipBase::Json(Json::Value root) {
void ClipBase::SetJsonValue(Json::Value root) {
// Set data from Json (if key is found)
if (root["position"] != Json::nullValue)