1#include <xrpl/basics/contract.h>
2#include <xrpl/beast/utility/instrumentation.h>
3#include <xrpl/json/Object.h>
4#include <xrpl/json/Output.h>
5#include <xrpl/json/Writer.h>
6#include <xrpl/json/json_value.h>
14 : parent_(parent), writer_(writer), enabled_(true)
37 enabled_ = that.enabled_;
39 that.parent_ =
nullptr;
40 that.writer_ =
nullptr;
41 that.enabled_ =
false;
48 *
this = std::move(that);
55 ripple::Throw<std::logic_error>(label +
": not enabled");
57 ripple::Throw<std::logic_error>(label +
": not writable");
108 : object_(object), key_(key)
115 return Proxy(*
this, key);
133 return append(
nullptr);
135 return append(v.
asInt());
137 return append(v.
asUInt());
143 return append(v.
asBool());
158 UNREACHABLE(
"Json::Array::append : invalid type");
168 return set(k,
nullptr);
193 UNREACHABLE(
"Json::Object::set : invalid type");
200template <
class Object>
204 XRPL_ASSERT(from.
isObjectOrNull(),
"Json::doCopyFrom : valid input type");
206 for (
auto& m : members)
218 doCopyFrom(to, from);
224 doCopyFrom(to, from);
Represents a JSON array being written to a Writer.
Object appendObject()
Append a new Object and return it.
Array appendArray()
Append a new Array and return it.
void append(Scalar const &)
Append a scalar to the Arrary.
void checkWritable(std::string const &label)
Collection & operator=(Collection &&c) noexcept
Proxy(Object &object, std::string const &key)
Represents a JSON object being written to a Writer.
Proxy operator[](std::string const &key)
void set(std::string const &key, Scalar const &)
Set a scalar value in the Object for a key.
Array setArray(std::string const &key)
Make a new Array at a key and return it.
Object setObject(std::string const &key)
Make a new Object at a key and return it.
Lightweight wrapper to tag static string.
bool isObjectOrNull() const
Members getMemberNames() const
Return a list of the member names.
std::string asString() const
Returns the unquoted string value.
An Object that contains its own Writer.
Writer implements an O(1)-space, O(1)-granular output JSON writer.
void finish()
Finish the collection most recently started.
void startRoot(CollectionType)
Start a new collection at the root level.
void startAppend(CollectionType)
Start a new collection inside an array.
void startSet(CollectionType, std::string const &key)
Start a new collection inside an object.
JSON (JavaScript Object Notation).
Output stringOutput(std::string &s)
Json::Value & appendArray(Json::Value &)
Append a new subarray to a Json array.
@ stringValue
UTF-8 string value.
@ arrayValue
array value (ordered list)
@ intValue
signed integer value
@ objectValue
object value (collection of name/value pairs).
@ uintValue
unsigned integer value
WriterObject stringWriterObject(std::string &)
Json::Value & appendObject(Json::Value &)
Append a new subobject to a Json object.
void copyFrom(Json::Value &to, Json::Value const &from)
Copy all the keys and values from one object into another.
void check(bool condition, std::string const &message)