rippled
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
Json Namespace Reference

JSON (JavaScript Object Notation). More...

Namespaces

namespace  detail
 

Classes

class  Array
 Represents a JSON array being written to a Writer. More...
 
class  Collection
 
class  Compact
 Decorator for streaming out compact json. More...
 
class  DefaultValueAllocator
 
struct  DummyValueAllocatorInitializer
 
struct  error
 
class  FastWriter
 Outputs a Value in JSON format without formatting (not human friendly). More...
 
struct  JsonMissingKeyError
 
class  JsonObject_test
 
struct  JsonTypeMismatchError
 
class  Object
 Represents a JSON object being written to a Writer. More...
 
class  Reader
 Unserialize a JSON document into a Value. More...
 
class  StaticString
 Lightweight wrapper to tag static string. More...
 
class  StyledStreamWriter
 Writes a Value in JSON format in a human friendly way, to a stream rather than to a string. More...
 
class  StyledWriter
 Writes a Value in JSON format in a human friendly way. More...
 
class  Value
 Represents a JSON value. More...
 
class  ValueAllocator
 Experimental do not use: Allocator to customize member name and string value memory management done by Value. More...
 
class  ValueConstIterator
 const iterator for object and array value. More...
 
class  ValueIterator
 Iterator for object and array value. More...
 
class  ValueIteratorBase
 base class for Value iterators. More...
 
class  Writer
 Writer implements an O(1)-space, O(1)-granular output JSON writer. More...
 
class  WriterBase
 Abstract class for writers. More...
 
class  WriterObject
 An Object that contains its own Writer. More...
 

Typedefs

using Int = int
 
using UInt = unsigned int
 
using Output = std::function< void(boost::beast::string_view const &)>
 

Enumerations

enum  ValueType {
  nullValue = 0 , intValue , uintValue , realValue ,
  stringValue , booleanValue , arrayValue , objectValue
}
 Type of the value held by a Value object. More...
 

Functions

std::istreamoperator>> (std::istream &, Value &)
 Read from 'sin' into 'root'.
 
bool operator== (StaticString x, StaticString y)
 
bool operator!= (StaticString x, StaticString y)
 
bool operator== (std::string const &x, StaticString y)
 
bool operator!= (std::string const &x, StaticString y)
 
bool operator== (StaticString x, std::string const &y)
 
bool operator!= (StaticString x, std::string const &y)
 
Value to_json (ripple::Number const &number)
 
bool operator== (Value const &, Value const &)
 
bool operator!= (Value const &x, Value const &y)
 
bool operator< (Value const &, Value const &)
 
bool operator<= (Value const &x, Value const &y)
 
bool operator> (Value const &x, Value const &y)
 
bool operator>= (Value const &x, Value const &y)
 
std::string valueToString (Int value)
 
std::string valueToString (UInt value)
 
std::string valueToString (double value)
 
std::string valueToString (bool value)
 
std::string valueToQuotedString (char const *value)
 
std::ostreamoperator<< (std::ostream &, Value const &root)
 Output using the StyledStreamWriter.
 
template<class Write >
void stream (Json::Value const &jv, Write const &write)
 Stream compact JSON to the specified function.
 
Json::ValuesetArray (Json::Value &, Json::StaticString const &key)
 Add a new subarray at a named key in a Json object.
 
Array setArray (Object &, Json::StaticString const &key)
 Add a new subarray at a named key in a Json object.
 
Json::ValueaddObject (Json::Value &, Json::StaticString const &key)
 Add a new subobject at a named key in a Json object.
 
Object addObject (Object &, Json::StaticString const &key)
 Add a new subobject at a named key in a Json object.
 
Json::ValueappendArray (Json::Value &)
 Append a new subarray to a Json array.
 
Array appendArray (Array &)
 Append a new subarray to a Json array.
 
Json::ValueappendObject (Json::Value &)
 Append a new subobject to a Json object.
 
Object appendObject (Array &)
 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 copyFrom (Object &to, Json::Value const &from)
 Copy all the keys and values from one object into another.
 
WriterObject stringWriterObject (std::string &)
 
Output stringOutput (std::string &s)
 
void outputJson (Json::Value const &, Output const &)
 Writes a minimal representation of a Json value to an Output in O(n) time.
 
std::string jsonAsString (Json::Value const &)
 Return the minimal string representation of a Json::Value in O(n) time.
 
std::string to_string (Value const &)
 Writes a Json::Value to an std::string.
 
std::string pretty (Value const &)
 Writes a Json::Value to an std::string.
 
void check (bool condition, std::string const &message)
 
template<>
ripple::AccountID getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<class T >
getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<>
std::string getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<>
bool getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<>
std::uint64_t getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<>
ripple::Buffer getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<class T >
std::optional< T > getOptional (Json::Value const &v, ripple::SField const &field)
 
template<>
ripple::PublicKey getOrThrow (Json::Value const &v, ripple::SField const &field)
 
template<>
ripple::STAmount getOrThrow (Json::Value const &v, ripple::SField const &field)
 
static std::string codePointToUTF8 (unsigned int cp)
 
static ValueAllocator *& valueAllocator ()
 
static int integerCmp (Int i, UInt ui)
 
static bool isControlCharacter (char ch)
 
static bool containsControlCharacter (char const *str)
 
static void uintToString (unsigned int value, char *&current)
 
 BEAST_DEFINE_TESTSUITE (JsonObject, json, ripple)
 

Variables

static struct Json::DummyValueAllocatorInitializer dummyValueAllocatorInitializer
 

Detailed Description

JSON (JavaScript Object Notation).

Typedef Documentation

◆ Int

using Json::Int = typedef int

Definition at line 26 of file json_forwards.h.

◆ UInt

using Json::UInt = typedef unsigned int

Definition at line 27 of file json_forwards.h.

◆ Output

using Json::Output = typedef std::function<void(boost::beast::string_view const&)>

Definition at line 32 of file include/xrpl/json/Output.h.

Enumeration Type Documentation

◆ ValueType

Type of the value held by a Value object.

Enumerator
nullValue 

'null' value

intValue 

signed integer value

uintValue 

unsigned integer value

realValue 

double value

stringValue 

UTF-8 string value.

booleanValue 

bool value

arrayValue 

array value (ordered list)

objectValue 

object value (collection of name/value pairs).

Definition at line 37 of file json_value.h.

Function Documentation

◆ operator>>()

std::istream & Json::operator>> ( std::istream sin,
Value root 
)

Read from 'sin' into 'root'.

Always keep comments from the input JSON.

This can be used to read a file into a particular sub-object. For example:

cin >> root["dir"]["file"];
cout << root;
Represents a JSON value.
Definition json_value.h:149

Result:

 {
"dir": {
    "file": {
 // The input stream JSON would be nested here.
    }
}
 }
Exceptions
std::exceptionon parse error.
See also
Json::operator<<()

Definition at line 956 of file json_reader.cpp.

◆ operator==() [1/4]

bool Json::operator== ( StaticString  x,
StaticString  y 
)

Definition at line 86 of file json_value.h.

◆ operator!=() [1/4]

bool Json::operator!= ( StaticString  x,
StaticString  y 
)

Definition at line 92 of file json_value.h.

◆ operator==() [2/4]

bool Json::operator== ( std::string const &  x,
StaticString  y 
)

Definition at line 98 of file json_value.h.

◆ operator!=() [2/4]

bool Json::operator!= ( std::string const &  x,
StaticString  y 
)

Definition at line 104 of file json_value.h.

◆ operator==() [3/4]

bool Json::operator== ( StaticString  x,
std::string const &  y 
)

Definition at line 110 of file json_value.h.

◆ operator!=() [3/4]

bool Json::operator!= ( StaticString  x,
std::string const &  y 
)

Definition at line 116 of file json_value.h.

◆ to_json()

Value Json::to_json ( ripple::Number const &  number)

Definition at line 444 of file json_value.h.

◆ operator==() [4/4]

bool Json::operator== ( Value const &  x,
Value const &  y 
)

Definition at line 438 of file json_value.cpp.

◆ operator!=() [4/4]

bool Json::operator!= ( Value const &  x,
Value const &  y 
)

Definition at line 453 of file json_value.h.

◆ operator<()

bool Json::operator< ( Value const &  x,
Value const &  y 
)

Definition at line 386 of file json_value.cpp.

◆ operator<=()

bool Json::operator<= ( Value const &  x,
Value const &  y 
)

Definition at line 461 of file json_value.h.

◆ operator>()

bool Json::operator> ( Value const &  x,
Value const &  y 
)

Definition at line 468 of file json_value.h.

◆ operator>=()

bool Json::operator>= ( Value const &  x,
Value const &  y 
)

Definition at line 474 of file json_value.h.

◆ valueToString() [1/4]

std::string Json::valueToString ( Int  value)

Definition at line 66 of file json_writer.cpp.

◆ valueToString() [2/4]

std::string Json::valueToString ( UInt  value)

Definition at line 85 of file json_writer.cpp.

◆ valueToString() [3/4]

std::string Json::valueToString ( double  value)

Definition at line 95 of file json_writer.cpp.

◆ valueToString() [4/4]

std::string Json::valueToString ( bool  value)

Definition at line 114 of file json_writer.cpp.

◆ valueToQuotedString()

std::string Json::valueToQuotedString ( char const *  value)

Definition at line 120 of file json_writer.cpp.

◆ operator<<()

std::ostream & Json::operator<< ( std::ostream sout,
Value const &  root 
)

Output using the StyledStreamWriter.

See also
Json::operator>>()
Json::operator>>().

Definition at line 728 of file json_writer.cpp.

◆ stream()

template<class Write >
void Json::stream ( Json::Value const &  jv,
Write const &  write 
)

Stream compact JSON to the specified function.

Parameters
jvThe Json::Value to write
writeInvocable with signature void(void const*, std::size_t) that is called when output should be written to the stream.

Definition at line 301 of file json_writer.h.

◆ setArray() [1/2]

Json::Value & Json::setArray ( Json::Value json,
Json::StaticString const &  key 
)

Add a new subarray at a named key in a Json object.

Definition at line 415 of file Object.h.

◆ setArray() [2/2]

Array Json::setArray ( Object json,
Json::StaticString const &  key 
)

Add a new subarray at a named key in a Json object.

Definition at line 421 of file Object.h.

◆ addObject() [1/2]

Json::Value & Json::addObject ( Json::Value json,
Json::StaticString const &  key 
)

Add a new subobject at a named key in a Json object.

Definition at line 427 of file Object.h.

◆ addObject() [2/2]

Object Json::addObject ( Object object,
Json::StaticString const &  key 
)

Add a new subobject at a named key in a Json object.

Definition at line 433 of file Object.h.

◆ appendArray() [1/2]

Json::Value & Json::appendArray ( Json::Value json)

Append a new subarray to a Json array.

Definition at line 439 of file Object.h.

◆ appendArray() [2/2]

Array Json::appendArray ( Array json)

Append a new subarray to a Json array.

Definition at line 445 of file Object.h.

◆ appendObject() [1/2]

Json::Value & Json::appendObject ( Json::Value json)

Append a new subobject to a Json object.

Definition at line 451 of file Object.h.

◆ appendObject() [2/2]

Object Json::appendObject ( Array json)

Append a new subobject to a Json object.

Definition at line 457 of file Object.h.

◆ copyFrom() [1/2]

void Json::copyFrom ( Json::Value to,
Json::Value const &  from 
)

Copy all the keys and values from one object into another.

Definition at line 232 of file Object.cpp.

◆ copyFrom() [2/2]

void Json::copyFrom ( Object to,
Json::Value const &  from 
)

Copy all the keys and values from one object into another.

Definition at line 241 of file Object.cpp.

◆ stringWriterObject()

WriterObject Json::stringWriterObject ( std::string s)

Definition at line 247 of file Object.cpp.

◆ stringOutput()

Output Json::stringOutput ( std::string s)

Definition at line 35 of file include/xrpl/json/Output.h.

◆ outputJson()

void Json::outputJson ( Json::Value const &  value,
Output const &  out 
)

Writes a minimal representation of a Json value to an Output in O(n) time.

Data is streamed right to the output, so only a marginal amount of memory is used. This can be very important for a very large Json::Value.

Definition at line 93 of file libxrpl/json/Output.cpp.

◆ jsonAsString()

std::string Json::jsonAsString ( Json::Value const &  value)

Return the minimal string representation of a Json::Value in O(n) time.

This requires a memory allocation for the full size of the output. If possible, use outputJson().

Definition at line 100 of file libxrpl/json/Output.cpp.

◆ to_string()

std::string Json::to_string ( Value const &  value)

Writes a Json::Value to an std::string.

Definition at line 28 of file to_string.cpp.

◆ pretty()

std::string Json::pretty ( Value const &  value)

Writes a Json::Value to an std::string.

Definition at line 34 of file to_string.cpp.

◆ check()

void Json::check ( bool  condition,
std::string const &  message 
)

Definition at line 253 of file json/Writer.h.

◆ getOrThrow() [1/8]

template<>
ripple::AccountID Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 131 of file AccountID.h.

◆ getOrThrow() [2/8]

template<class T >
T Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 56 of file json_get_or_throw.h.

◆ getOrThrow() [3/8]

template<>
std::string Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 63 of file json_get_or_throw.h.

◆ getOrThrow() [4/8]

template<>
bool Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 79 of file json_get_or_throw.h.

◆ getOrThrow() [5/8]

template<>
std::uint64_t Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 96 of file json_get_or_throw.h.

◆ getOrThrow() [6/8]

template<>
ripple::Buffer Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 129 of file json_get_or_throw.h.

◆ getOptional()

template<class T >
std::optional< T > Json::getOptional ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 144 of file json_get_or_throw.h.

◆ getOrThrow() [7/8]

template<>
ripple::PublicKey Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 293 of file PublicKey.h.

◆ getOrThrow() [8/8]

template<>
ripple::STAmount Json::getOrThrow ( Json::Value const &  v,
ripple::SField const &  field 
)

Definition at line 718 of file STAmount.h.

◆ codePointToUTF8()

static std::string Json::codePointToUTF8 ( unsigned int  cp)
static

Definition at line 38 of file json_reader.cpp.

◆ valueAllocator()

static ValueAllocator *& Json::valueAllocator ( )
static

Definition at line 84 of file json_value.cpp.

◆ integerCmp()

static int Json::integerCmp ( Int  i,
UInt  ui 
)
static

Definition at line 376 of file json_value.cpp.

◆ isControlCharacter()

static bool Json::isControlCharacter ( char  ch)
static

Definition at line 37 of file json_writer.cpp.

◆ containsControlCharacter()

static bool Json::containsControlCharacter ( char const *  str)
static

Definition at line 43 of file json_writer.cpp.

◆ uintToString()

static void Json::uintToString ( unsigned int  value,
char *&  current 
)
static

Definition at line 54 of file json_writer.cpp.

◆ BEAST_DEFINE_TESTSUITE()

Json::BEAST_DEFINE_TESTSUITE ( JsonObject  ,
json  ,
ripple   
)

Variable Documentation

◆ dummyValueAllocatorInitializer

struct Json::DummyValueAllocatorInitializer Json::dummyValueAllocatorInitializer
static