mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add new JSON API for better abstraction and for supporting strict JSON parsing
This commit is contained in:
committed by
Alex Beregszaszi
parent
dcc4083b23
commit
0f29ac4e56
+19
-12
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user