Crow  1.1
A C++ microframework for the web
 
Loading...
Searching...
No Matches
crow::json::wvalue Class Reference

JSON write value. More...

#include <json.h>

Inheritance diagram for crow::json::wvalue:
crow::returnable

Public Types

using object = detail::object_policy::object_type< wvalue >
 
using list = std::vector< wvalue >
 

Public Member Functions

type t () const
 
 wvalue (std::nullptr_t)
 
 wvalue (bool value)
 
 wvalue (std::uint8_t value)
 
 wvalue (std::uint16_t value)
 
 wvalue (std::uint32_t value)
 
 wvalue (std::uint64_t value)
 
 wvalue (std::int8_t value)
 
 wvalue (std::int16_t value)
 
 wvalue (std::int32_t value)
 
 wvalue (std::int64_t value)
 
 wvalue (float value)
 
 wvalue (double value)
 
 wvalue (char const *value)
 
 wvalue (std::string const &value)
 
 wvalue (std::string &&value)
 
 wvalue (std::initializer_list< std::pair< std::string const, wvalue > > initializer_list)
 
 wvalue (object const &value)
 
 wvalue (object &&value)
 
 wvalue (const list &r)
 
 wvalue (list &r)
 
 wvalue (const rvalue &r)
 Create a write value from a read value (useful for editing JSON strings).
 
 wvalue (const wvalue &r)
 
 wvalue (wvalue &&r)
 
wvalue & operator= (wvalue &&r)
 
void clear ()
 Used for compatibility, same as reset()
 
void reset ()
 
wvalue & operator= (std::nullptr_t)
 
wvalue & operator= (bool value)
 
wvalue & operator= (float value)
 
wvalue & operator= (double value)
 
wvalue & operator= (unsigned short value)
 
wvalue & operator= (short value)
 
wvalue & operator= (long long value)
 
wvalue & operator= (long value)
 
wvalue & operator= (int value)
 
wvalue & operator= (unsigned long long value)
 
wvalue & operator= (unsigned long value)
 
wvalue & operator= (unsigned int value)
 
wvalue & operator= (const char *str)
 
wvalue & operator= (const std::string &str)
 
wvalue & operator= (list &&v)
 
template<typename T >
wvalue & operator= (const std::vector< T > &v)
 
wvalue & operator= (std::initializer_list< std::pair< std::string const, wvalue > > initializer_list)
 
wvalue & operator= (object const &value)
 
wvalue & operator= (object &&value)
 
wvalue & operator= (std::function< std::string(std::string &)> &&func)
 
wvalue & operator[] (unsigned index)
 
const wvalue & operator[] (unsigned index) const
 
bool has (const char *key) const
 Check if the object contains the given key.
 
bool has (const std::string &key) const
 Check if the object contains the given key.
 
size_t count (const std::string &str) const
 
wvalue & operator[] (const std::string &str)
 
const wvalue & operator[] (const std::string &str) const
 
std::vector< std::string > keys () const
 
std::string execute (std::string txt="") const
 
std::size_t size () const
 If the wvalue is a list, it returns the length of the list, otherwise it returns 1.
 
size_t estimate_length () const
 Returns an estimated size of the value in bytes.
 
std::string dump (const size_t indent, const char separator=' ') const
 
std::string dump () const override
 
 operator std::string () const
 Return json string.
 
- Public Member Functions inherited from crow::returnable
 returnable (std::string ctype)
 

Static Public Member Functions

static crow::json::wvalue empty_object ()
 Create an empty json value (outputs "{}" instead of a "null" string)
 

Friends

class crow::mustache::template_t
 
struct wvalue_reader
 

Additional Inherited Members

- Public Attributes inherited from crow::returnable
std::string content_type
 

Detailed Description

JSON write value.

Value can mean any json value, including a JSON object.
Write means this class is used to primarily assemble JSON objects using keys and values and export those into a string. The object container is selected at compile time. By default, object keys use an std::unordered_map; CROW_JSON_USE_MAP selects lexicographically sorted keys, while CROW_JSON_USE_INSERTION_ORDER preserves the order of newly inserted keys. Updating an existing key does not change its position. These options affect the order of serialized JSON object keys and cannot be used together.

Member Function Documentation

◆ dump()

std::string crow::json::wvalue::dump ( ) const
inlineoverridevirtual

Implements crow::returnable.


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