Added createJson method to make writing json easier

This commit is contained in:
Ali92hm 2017-05-22 13:39:38 -07:00 committed by Alex Beregszaszi
parent 8bb96eaaf5
commit 1a9c503e93
2 changed files with 10 additions and 0 deletions

View File

@ -508,6 +508,11 @@ void CommandLineInterface::createFile(string const& _fileName, string const& _da
BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + pathName)); BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + pathName));
} }
void CommandLineInterface::createJson(string const& _fileName, Json::Value const& _json)
{
createFile(boost::filesystem::basename(_fileName) + string(".json"), dev::jsonCompactPrint(_json));
}
bool CommandLineInterface::parseArguments(int _argc, char** _argv) bool CommandLineInterface::parseArguments(int _argc, char** _argv)
{ {
// Declare the supported options. // Declare the supported options.

View File

@ -81,6 +81,11 @@ private:
/// @arg _data to be written /// @arg _data to be written
void createFile(std::string const& _fileName, std::string const& _data); void createFile(std::string const& _fileName, std::string const& _data);
/// Create a json file in the given directory
/// @arg _fileName the name of the file (the extension will be replaced with .json)
/// @arg _json to be written
void createJson(std::string const& _fileName, Json::Value const& _json);
bool m_error = false; ///< If true, some error occurred. bool m_error = false; ///< If true, some error occurred.
bool m_onlyAssemble = false; bool m_onlyAssemble = false;