Wt  4.11.1
Public Member Functions | Static Public Attributes | List of all members
Wt::Json::Object Class Reference

A JSON object. More...

#include <Object.h>

Inherits std::map< K, T >.

Public Member Functions

 Object ()
 Default constructor.
 
 Object (const Object &other)
 Copy constructor.
 
void swap (Object &other)
 Swap operation. More...
 
Objectoperator= (const Object &other)
 Assignment operator.
 
 Object (Object &&other)
 Move constructor.
 
 Object (std::initializer_list< std::pair< const std::string, Value > > list)
 Initializer list constructor.
 
Objectoperator= (Object &&other)
 Move assignment operator.
 
std::set< std::string > names () const
 Returns the key set. More...
 
bool contains (const std::string &name) const
 Returns whether a member exists. More...
 
Type type (const std::string &name) const
 Returns the type of a given member. More...
 
bool isNull (const std::string &name) const
 Returns whether the value for a member is null (or not defined). More...
 
const Valueget (const std::string &name) const
 Returns the value for a member (or null if not defined). More...
 

Static Public Attributes

static Object Empty
 Empty object constant.
 

Detailed Description

A JSON object.

This class represents a JSON object, which defines a value map. It is implemented as a std::map<std::string,Json::Value>. It is therefore possible to use the std::map API to deal with it.

However, a number of additional methods have been added to more conveniently query the existence and the type of contained objects. A get() method can be used to return a member value, which returns Value::Null if the member is not defined.

Member Function Documentation

◆ contains()

bool Wt::Json::Object::contains ( const std::string &  name) const

Returns whether a member exists.

This returns whether the name is in the names() set.

◆ get()

const Value & Wt::Json::Object::get ( const std::string &  name) const

Returns the value for a member (or null if not defined).

Returns the value associated with member name or null if no value has been associated with this member name.

◆ isNull()

bool Wt::Json::Object::isNull ( const std::string &  name) const

Returns whether the value for a member is null (or not defined).

See also
get(), Value::isNull()

◆ names()

std::set< std::string > Wt::Json::Object::names ( ) const

Returns the key set.

This returns the member names: these are the members for which values have been associated in this object.

Note
This may include members with explicit Value::Null values.

◆ swap()

void Wt::Json::Object::swap ( Object other)

Swap operation.

This swaps the contents of two objects.

◆ type()

Type Wt::Json::Object::type ( const std::string &  name) const

Returns the type of a given member.

This method returns the type of the value for members that are included, or returns Json::Type::Null for when no value is associated with name.