diff options
author | chriseth <chris@ethereum.org> | 2018-03-08 03:20:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 03:20:57 +0800 |
commit | dfe3193c7382c80f1814247a162663a97c3f5e67 (patch) | |
tree | d0540c2dfc43a76f0add46840f60ff2e28604a19 /libdevcore/JSON.h | |
parent | 3155dd8058672ce8f04bc2c0f2536cb549067d0a (diff) | |
parent | 15920dc75dd5a46a036d5ff16fb8eee0534be6e1 (diff) | |
download | dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.gz dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.bz2 dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.lz dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.xz dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.zst dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.zip |
Merge pull request #3678 from ethereum/develop
Merge develop into release.
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); } |