Files
libopenshot/src/Json.cpp
Frank Dana 59138ea3e4 Adopt license management via Reuse project/tool (#711)
* reuse-managed license/copyright headers

reuse is a tool for compliance with the REUSE recommendations. See
<https://reuse.software/> for more information, and
<https://reuse.readthedocs.io/> for the online documentation.

* Set jsoncpp license
* Add MIT license for Decklink sources
* Explicitly license examples/
  - Add headers to source files
  - Change blanket licensing in .reuse/dep5 to only cover binary media
  - Import CC-BY-3.0 license and assign to sintel_trailer
2021-10-16 01:26:26 -04:00

34 lines
780 B
C++

/**
* @file
* @brief Helper functions for Json parsing
* @author FeRD (Frank Dana) <ferdnyc@gmail.com>
*
* @ref License
*/
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "Json.h"
#include "Exceptions.h"
const Json::Value openshot::stringToJson(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 openshot::InvalidJSON("JSON could not be parsed (or is invalid)");
return root;
}