JSON Voorhees
Killer JSON for C++
Value

JSON value instances. More...

Classes

class  jsonv::kind_error
 Thrown from various value methods when attempting to perform an operation which is not valid for the kind of value. More...
 
class  jsonv::value
 Represents a single JSON value, which can be any one of a potential kind, each behaving slightly differently. More...
 
class  jsonv::object_node_handle
 A node handle used when a value is kind::object to access elements of the object in potentially destructive manner. More...
 

Enumerations

enum  jsonv::kind : unsigned char {
  null, object, array, string,
  integer, decimal, boolean
}
 Describes the kind of data a value holds. More...
 

Functions

JSONV_PUBLIC std::ostream & jsonv::operator<< (std::ostream &, const kind &)
 Print out the name of the kind. More...
 
JSONV_PUBLIC std::string jsonv::to_string (const kind &)
 Get the name of the kind. More...
 
JSONV_PUBLIC std::string jsonv::to_string (const value &)
 Get a string representation of the given value. More...
 
JSONV_PUBLIC value jsonv::operator""_json (const char *str, std::size_t len)
 A user-defined literal for parsing JSON. More...
 
JSONV_PUBLIC void jsonv::swap (value &a, value &b) noexcept
 Swap the values a and b. More...
 
JSONV_PUBLIC value jsonv::array ()
 Create an empty array value. More...
 
JSONV_PUBLIC value jsonv::array (std::initializer_list< value > source)
 Create an array value from the given source. More...
 
template<typename TForwardIterator >
value jsonv::array (TForwardIterator first, TForwardIterator last)
 Create an array with contents defined by range [first, last). More...
 
JSONV_PUBLIC value jsonv::object ()
 Create an empty object. More...
 
JSONV_PUBLIC value jsonv::object (std::initializer_list< std::pair< std::string, value >> source)
 Create an object with key-value pairs from the given source. More...
 
JSONV_PUBLIC value jsonv::object (std::initializer_list< std::pair< std::wstring, value >> source)
 
template<typename TForwardIterator >
value jsonv::object (TForwardIterator first, TForwardIterator last)
 Create an object whose contents are defined by range [first, last). More...
 

Variables

JSONV_PUBLIC const value jsonv::null
 An instance with kind::null. More...
 

Detailed Description

JSON value instances.

Enumeration Type Documentation

enum jsonv::kind : unsigned char
strong

Describes the kind of data a value holds.

See value for more information.

See also
http://json.org/

Definition at line 69 of file value.hpp.

Function Documentation

JSONV_PUBLIC value jsonv::array ( )

Create an empty array value.

JSONV_PUBLIC value jsonv::array ( std::initializer_list< value source)

Create an array value from the given source.

template<typename TForwardIterator >
value jsonv::array ( TForwardIterator  first,
TForwardIterator  last 
)

Create an array with contents defined by range [first, last).

Definition at line 1023 of file value.hpp.

JSONV_PUBLIC value jsonv::object ( )

Create an empty object.

JSONV_PUBLIC value jsonv::object ( std::initializer_list< std::pair< std::string, value >>  source)

Create an object with key-value pairs from the given source.

template<typename TForwardIterator >
value jsonv::object ( TForwardIterator  first,
TForwardIterator  last 
)

Create an object whose contents are defined by range [first, last).

Definition at line 1039 of file value.hpp.

JSONV_PUBLIC value jsonv::operator""_json ( const char *  str,
std::size_t  len 
)

A user-defined literal for parsing JSON.

Uses the default (non-strict) parse_options.

R"({
"taco": "cat",
"burrito": "dog",
"whatever": [ "goes", "here", 1, 2, 3, 4 ]
})"_json;
JSONV_PUBLIC std::ostream& jsonv::operator<< ( std::ostream &  ,
const kind  
)

Print out the name of the kind.

JSONV_PUBLIC void jsonv::swap ( value a,
value b 
)
noexcept

Swap the values a and b.

JSONV_PUBLIC std::string jsonv::to_string ( const kind )

Get the name of the kind.

JSONV_PUBLIC std::string jsonv::to_string ( const value )

Get a string representation of the given value.

Variable Documentation

JSONV_PUBLIC const value jsonv::null

An instance with kind::null.

This is intended to be used for convenience and readability (as opposed to using the default constructor of value.