diff options
Diffstat (limited to 'libdevcore/JSON.h')
-rw-r--r-- | libdevcore/JSON.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/libdevcore/JSON.h b/libdevcore/JSON.h index 8499d623..1ce822cd 100644 --- a/libdevcore/JSON.h +++ b/libdevcore/JSON.h @@ -24,21 +24,28 @@ #include <json/json.h> -namespace dev -{ +#include <string> + +namespace dev { /// Serialise the JSON object (@a _input) with indentation -inline std::string jsonPrettyPrint(Json::Value const& _input) -{ - return Json::StyledWriter().write(_input); -} +std::string jsonPrettyPrint(Json::Value const& _input); /// Serialise the JSON object (@a _input) without indentation -inline std::string jsonCompactPrint(Json::Value const& _input) -{ - Json::FastWriter writer; - writer.omitEndingLineFeed(); - return writer.write(_input); -} +std::string jsonCompactPrint(Json::Value const& _input); + +/// Parse a JSON string (@a _input) with enabled strict-mode and writes resulting JSON object to (@a _json) +/// \param _input JSON input string +/// \param _json [out] resulting JSON object +/// \param _errs [out] Formatted error messages +/// \return \c true if the document was successfully parsed, \c false if an error occurred. +bool jsonParseStrict(std::string const& _input, Json::Value& _json, std::string* _errs = nullptr); + +/// Parse a JSON string (@a _input) and writes resulting JSON object to (@a _json) +/// \param _input JSON input string +/// \param _json [out] resulting JSON object +/// \param _errs [out] Formatted error messages +/// \return \c true if the document was successfully parsed, \c false if an error occurred. +bool jsonParse(std::string const& _input, Json::Value& _json, std::string* _errs = nullptr); } |