rippled
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Json::Object Class Reference

Represents a JSON object being written to a Writer. More...

Inheritance diagram for Json::Object:
Inheritance graph
[legend]
Collaboration diagram for Json::Object:
Collaboration graph
[legend]

Classes

class  Proxy
 
class  Root
 

Public Member Functions

template<typename Scalar >
void set (std::string const &key, Scalar const &)
 Set a scalar value in the Object for a key. More...
 
void set (std::string const &key, Json::Value const &)
 
Proxy operator[] (std::string const &key)
 
Proxy operator[] (Json::StaticString const &key)
 
Object setObject (std::string const &key)
 Make a new Object at a key and return it. More...
 
Array setArray (std::string const &key)
 Make a new Array at a key and return it. More...
 

Protected Member Functions

 Object (Collection *parent, Writer *w)
 
void checkWritable (std::string const &label)
 

Protected Attributes

Collectionparent_
 
Writerwriter_
 
bool enabled_
 

Friends

class Array
 

Detailed Description

Represents a JSON object being written to a Writer.

Definition at line 178 of file Object.h.

Constructor & Destructor Documentation

◆ Object()

Json::Object::Object ( Collection parent,
Writer w 
)
protected

Definition at line 230 of file Object.h.

Member Function Documentation

◆ set() [1/2]

template<typename Scalar >
void Json::Object::set ( std::string const &  key,
Scalar const &  value 
)

Set a scalar value in the Object for a key.

A JSON scalar is a single value - a number, string, boolean, nullptr or a Json::Value.

set() throws an exception if this object is disabled (which means that one of its children is enabled).

In a debug build, set() also throws an exception if the key has already been set() before.

An operator[] is provided to allow writing object["key"] = scalar;.

Definition at line 406 of file Object.h.

◆ set() [2/2]

void Json::Object::set ( std::string const &  key,
Json::Value const &  v 
)

Definition at line 175 of file Object.cpp.

◆ operator[]() [1/2]

Object::Proxy Json::Object::operator[] ( std::string const &  key)

Definition at line 126 of file Object.cpp.

◆ operator[]() [2/2]

Object::Proxy Json::Object::operator[] ( Json::StaticString const &  key)

Definition at line 132 of file Object.cpp.

◆ setObject()

Object Json::Object::setObject ( std::string const &  key)

Make a new Object at a key and return it.

This Object is disabled until that sub-object is destroyed. Throws an exception if this Object was already disabled.

Definition at line 81 of file Object.cpp.

◆ setArray()

Array Json::Object::setArray ( std::string const &  key)

Make a new Array at a key and return it.

This Object is disabled until that sub-array is destroyed. Throws an exception if this Object was already disabled.

Definition at line 90 of file Object.cpp.

◆ checkWritable()

void Json::Collection::checkWritable ( std::string const &  label)
protectedinherited

Definition at line 65 of file Object.cpp.

Friends And Related Function Documentation

◆ Array

friend class Array
friend

Definition at line 229 of file Object.h.

Member Data Documentation

◆ parent_

Collection* Json::Collection::parent_
protectedinherited

Definition at line 168 of file Object.h.

◆ writer_

Writer* Json::Collection::writer_
protectedinherited

Definition at line 169 of file Object.h.

◆ enabled_

bool Json::Collection::enabled_
protectedinherited

Definition at line 170 of file Object.h.