You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Merge pull request #396 from ferdnyc/json-parsing
Behind-the-scenes code tidying for Json data handling
This commit is contained in:
@@ -2434,14 +2434,14 @@ int64_t FFmpegReader::GetSmallestAudioFrame() {
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
std::string FFmpegReader::Json() {
|
||||
std::string FFmpegReader::Json() const {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
}
|
||||
|
||||
// Generate Json::JsonValue for this object
|
||||
Json::Value FFmpegReader::JsonValue() {
|
||||
// Generate Json::Value for this object
|
||||
Json::Value FFmpegReader::JsonValue() const {
|
||||
|
||||
// Create root json object
|
||||
Json::Value root = ReaderBase::JsonValue(); // get parent properties
|
||||
@@ -2453,23 +2453,11 @@ Json::Value FFmpegReader::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void FFmpegReader::SetJson(std::string value) {
|
||||
void FFmpegReader::SetJson(const std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
std::string errors;
|
||||
bool success = reader->parse(value.c_str(), value.c_str() + value.size(),
|
||||
&root, &errors);
|
||||
delete reader;
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try {
|
||||
const Json::Value root = openshot::stringToJson(value);
|
||||
// Set all values that match
|
||||
SetJsonValue(root);
|
||||
}
|
||||
@@ -2479,8 +2467,8 @@ void FFmpegReader::SetJson(std::string value) {
|
||||
}
|
||||
}
|
||||
|
||||
// Load Json::JsonValue into this object
|
||||
void FFmpegReader::SetJsonValue(Json::Value root) {
|
||||
// Load Json::Value into this object
|
||||
void FFmpegReader::SetJsonValue(const Json::Value root) {
|
||||
|
||||
// Set parent data
|
||||
ReaderBase::SetJsonValue(root);
|
||||
|
||||
Reference in New Issue
Block a user