rippled
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
Json Namespace Reference

JSON (JavaScript Object Notation). More...

Namespaces

 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...
 
class  JsonObject_test
 
class  JsonWriter_test
 
class  Object
 Represents a JSON object being written to a Writer. More...
 
struct  Output_test
 
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

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

Function Documentation

◆ codePointToUTF8()

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

Definition at line 34 of file json_reader.cpp.

◆ operator>>()

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

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;

Result:

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

Definition at line 953 of file json_reader.cpp.

◆ valueAllocator()

static ValueAllocator*& Json::valueAllocator ( )
static

Definition at line 77 of file json_value.cpp.

◆ integerCmp()

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

Definition at line 356 of file json_value.cpp.

◆ operator<()

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

Definition at line 367 of file json_value.cpp.

◆ operator==() [1/4]

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

Definition at line 416 of file json_value.cpp.

◆ isControlCharacter()

static bool Json::isControlCharacter ( char  ch)
static

Definition at line 30 of file json_writer.cpp.

◆ containsControlCharacter()

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

Definition at line 36 of file json_writer.cpp.

◆ uintToString()

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

Definition at line 47 of file json_writer.cpp.

◆ valueToString() [1/4]

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

Definition at line 59 of file json_writer.cpp.

◆ valueToString() [2/4]

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

Definition at line 78 of file json_writer.cpp.

◆ valueToString() [3/4]

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

Definition at line 88 of file json_writer.cpp.

◆ valueToString() [4/4]

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

Definition at line 107 of file json_writer.cpp.

◆ valueToQuotedString()

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

Definition at line 113 of file json_writer.cpp.

◆ operator<<()

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

Output using the StyledStreamWriter.

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

Definition at line 714 of file json_writer.cpp.

◆ 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 226 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 235 of file Object.cpp.

◆ stringWriterObject()

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

Definition at line 241 of file Object.cpp.

◆ outputJson()

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

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 90 of file Output.cpp.

◆ jsonAsString()

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

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 97 of file Output.cpp.

◆ to_string()

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

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

Definition at line 26 of file to_string.cpp.

◆ pretty()

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

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

Definition at line 32 of file to_string.cpp.

◆ operator==() [2/4]

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

Definition at line 83 of file json_value.h.

◆ operator!=() [1/4]

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

Definition at line 89 of file json_value.h.

◆ operator==() [3/4]

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

Definition at line 95 of file json_value.h.

◆ operator!=() [2/4]

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

Definition at line 101 of file json_value.h.

◆ operator==() [4/4]

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

Definition at line 107 of file json_value.h.

◆ operator!=() [3/4]

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

Definition at line 113 of file json_value.h.

◆ operator!=() [4/4]

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

Definition at line 440 of file json_value.h.

◆ operator<=()

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

Definition at line 449 of file json_value.h.

◆ operator>()

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

Definition at line 455 of file json_value.h.

◆ operator>=()

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

Definition at line 461 of file json_value.h.

◆ 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 300 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 414 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 420 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 426 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 432 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 438 of file Object.h.

◆ appendArray() [2/2]

Array Json::appendArray ( Array json)

Append a new subarray to a Json array.

Definition at line 444 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 450 of file Object.h.

◆ appendObject() [2/2]

Object Json::appendObject ( Array json)

Append a new subobject to a Json object.

Definition at line 456 of file Object.h.

◆ stringOutput()

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

Definition at line 33 of file json/Output.h.

◆ check()

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

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

◆ BEAST_DEFINE_TESTSUITE() [1/3]

Json::BEAST_DEFINE_TESTSUITE ( JsonObject  ,
ripple_basics  ,
ripple   
)

◆ BEAST_DEFINE_TESTSUITE() [2/3]

Json::BEAST_DEFINE_TESTSUITE ( Output  ,
ripple_basics  ,
ripple   
)

◆ BEAST_DEFINE_TESTSUITE() [3/3]

Json::BEAST_DEFINE_TESTSUITE ( JsonWriter  ,
ripple_basics  ,
ripple   
)

Variable Documentation

◆ dummyValueAllocatorInitializer

struct Json::DummyValueAllocatorInitializer Json::dummyValueAllocatorInitializer
static
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::root
Number root(Number f, unsigned d)
Definition: Number.cpp:624