userver: formats::json::Object Class Reference
Loading...
Searching...
No Matches
formats::json::Object Class Referencefinal

#include <userver/formats/json/object.hpp>

Detailed Description

Non-mutable JSON object representation.

This class is implemented in terms of formats::json::Value and cannot represent anything else but a JSON object. Use it when you need to explicitly state that only JSON object is expected.

Definition at line 20 of file object.hpp.

+ Inheritance diagram for formats::json::Object:

Public Member Functions

 Object ()
 Creates empty object.
 
 Object (const Value &value)
 
 Object (Value &&value)
 
 Object (ValueBuilder &&builder)
 Creates object extracting value from the builder.
 
 Object (const Object &)=default
 
 Object (Object &&) noexcept=default
 
Objectoperator= (const Object &) &=default
 
Objectoperator= (Object &&) noexcept=default
 
const ValueGetValue () const &
 Returns formats::json::Value.
 
Value && ExtractValue () &&
 Returns formats::json::Value.
 
Value operator[] (std::size_t index) const =delete
 
bool operator== (const Object &other) const
 Compares values.
 
bool operator!= (const Object &other) const
 
Object Clone () const
 Returns a deep copy of object (see formats::json::Value::Clone).
 
Value operator[] (std::string_view key) const
 
bool IsEmpty () const
 
std::size_t GetSize () const
 
template<typename T>
auto As () const
 
template<typename T, typename First, typename... Rest>
auto As (First &&default_arg, Rest &&... more_default_args) const
 
template<typename T>
auto As (DefaultConstructed) const
 
template<typename T>
ConvertTo () const
 
template<typename T, typename First, typename... Rest>
ConvertTo (First &&default_arg, Rest &&... more_default_args) const
 
bool HasMember (std::string_view key) const
 
std::string GetPath () const
 
bool IsRoot () const noexcept
 

Private Member Functions

bool operator== (const Value &other) const
 Compares values.
 
bool operator!= (const Value &other) const
 

Constructor & Destructor Documentation

◆ Object() [1/3]

formats::json::Object::Object ( const Value & value)
inlineexplicit
Exceptions
TypeMismatchExceptionif value is not an object

Definition at line 26 of file object.hpp.

◆ Object() [2/3]

formats::json::Object::Object ( Value && value)
inlineexplicit
Exceptions
TypeMismatchExceptionif value is not an object

Definition at line 29 of file object.hpp.

◆ Object() [3/3]

formats::json::Object::Object ( ValueBuilder && builder)
explicit

Creates object extracting value from the builder.

Exceptions
TypeMismatchExceptionif extracted value is not an object.

Member Function Documentation

◆ As() [1/3]

template<typename T>
auto formats::json::Value::As ( ) const
See also
formats::json::Value::As

Definition at line 185 of file value.hpp.

◆ As() [2/3]

template<typename T>
auto formats::json::Value::As ( Value::DefaultConstructed ) const
See also
formats::json::Value::As

Definition at line 197 of file value.hpp.

◆ As() [3/3]

template<typename T, typename First, typename... Rest>
auto formats::json::Value::As ( First && default_arg,
Rest &&... more_default_args ) const
See also
formats::json::Value::As

Definition at line 191 of file value.hpp.

◆ Clone()

Object formats::json::Object::Clone ( ) const
inline

Returns a deep copy of object (see formats::json::Value::Clone).

Definition at line 79 of file object.hpp.

◆ ConvertTo() [1/2]

template<typename T>
T formats::json::Value::ConvertTo ( ) const
See also
formats::json::Value::ConvertTo

Definition at line 202 of file value.hpp.

◆ ConvertTo() [2/2]

template<typename T, typename First, typename... Rest>
T formats::json::Value::ConvertTo ( First && default_arg,
Rest &&... more_default_args ) const
See also
formats::json::Value::ConvertTo

Definition at line 207 of file value.hpp.

◆ ExtractValue()

Value && formats::json::Object::ExtractValue ( ) &&
inline

Returns formats::json::Value.

Definition at line 45 of file object.hpp.

◆ GetPath()

std::string formats::json::Value::GetPath ( ) const

◆ GetSize()

std::size_t formats::json::Value::GetSize ( ) const

◆ GetValue()

const Value & formats::json::Object::GetValue ( ) const &
inline

Returns formats::json::Value.

Definition at line 42 of file object.hpp.

◆ HasMember()

bool formats::json::Value::HasMember ( std::string_view key) const

◆ IsEmpty()

bool formats::json::Value::IsEmpty ( ) const

◆ IsRoot()

bool formats::json::Value::IsRoot ( ) const
noexcept

◆ operator!=()

bool formats::json::Object::operator!= ( const Object & other) const
inline

Definition at line 61 of file object.hpp.

◆ operator==()

bool formats::json::Object::operator== ( const Object & other) const
inline

Compares values.

Definition at line 60 of file object.hpp.

◆ operator[]()

Value formats::json::Value::operator[] ( std::string_view key) const

The documentation for this class was generated from the following file: