Click
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Json Class Reference

Json data. More...

Inherits JsonStatics.

Public Types

enum  json_type {
  j_null = 0 , j_array , j_object , j_int ,
  j_double , j_bool , j_string
}
 
typedef int size_type
 
typedef Pair< const String, Json > object_value_type
 
typedef Json array_value_type
 
typedef bool(Json::* unspecified_bool_type) () const
 
typedef uninitialized_type uninitialized_t
 

Public Member Functions

const char * class_name () const
 
 Json ()
 Construct a null Json.
 
 Json (const uninitialized_t &)
 Construct an uninitialized timestamp.
 
 Json (const Json &x)
 Construct a Json copy of x.
 
 Json (int x)
 Construct simple Json values.
 
 Json (unsigned x)
 
 Json (long x)
 
 Json (unsigned long x)
 
 Json (double x)
 
 Json (bool x)
 
 Json (const String &x)
 
 Json (const char *x)
 
template<typename T >
 Json (const Vector< T > &x)
 Construct an array Json containing the elements of x.
 
template<typename T >
 Json (T first, T last)
 Construct an array Json containing the elements in [first, last).
 
template<typename T >
 Json (const HashTable< String, T > &x)
 Construct an object Json containing the values in x.
 
 operator unspecified_bool_type () const
 Return true if this Json is not null.
 
bool operator! () const
 Return true if this Json is null.
 
json_type type () const
 Return this Json's type.
 
bool is_null () const
 Test this Json's type.
 
bool is_int () const
 
bool is_double () const
 
bool is_number () const
 
bool is_bool () const
 
bool is_string () const
 
bool is_array () const
 
bool is_object () const
 
bool is_primitive () const
 Test if this Json is a primitive value, not including null.
 
bool empty () const
 Return true if this Json is null, an empty array, or an empty object.
 
size_type size () const
 Return the number of elements in this complex Json.
 
long to_i () const
 Return this Json converted to an integer.
 
uint64_t to_u64 () const
 Return this Json converted to a 64-bit unsigned integer.
 
bool to_i (int &x) const
 Extract this integer Json's value into x.
 
bool to_i (unsigned &x) const
 
bool to_i (long &x) const
 
bool to_i (unsigned long &x) const
 
long as_i () const
 Return the integer value of this numeric Json.
 
double to_d () const
 Return this Json converted to a double.
 
bool to_d (double &x) const
 Extract this numeric Json's value into x.
 
double as_d () const
 Return the double value of this numeric Json.
 
bool to_b () const
 Return this Json converted to a boolean.
 
bool to_b (bool &x) const
 Extract this boolean Json's value into x.
 
bool as_b () const
 Return the value of this boolean Json.
 
const String & to_s () const
 Return this Json converted to a string.
 
bool to_s (String &x) const
 Extract this string Json's value into x.
 
const String & as_s () const
 Return the value of this string Json.
 
const char * c_str () const
 Return to_s().c_str().
 
size_type count (const StringRef &key) const
 Return 1 if this object Json contains key, 0 otherwise.
 
const Json & get (const StringRef &key) const
 Return the value at key in an object or array Json.
 
Json & get_insert (const String &key)
 Return a reference to the value of key in an object Json.
 
Json & get_insert (const StringRef &key)
 
Json & get_insert (const char *key)
 
long get_i (const StringRef &key) const
 Return get(key).to_i().
 
double get_d (const StringRef &key) const
 Return get(key).to_d().
 
bool get_b (const StringRef &key) const
 Return get(key).to_b().
 
const String & get_s (const StringRef &key) const
 Return get(key).to_s().
 
const Json_get_proxy get (const StringRef &key, Json &x) const
 Extract this object Json's value at key into x.
 
const Json_get_proxy get (const StringRef &key, int &x) const
 
const Json_get_proxy get (const StringRef &key, unsigned &x) const
 
const Json_get_proxy get (const StringRef &key, long &x) const
 
const Json_get_proxy get (const StringRef &key, unsigned long &x) const
 
const Json_get_proxy get (const StringRef &key, double &x) const
 
const Json_get_proxy get (const StringRef &key, bool &x) const
 
const Json_get_proxy get (const StringRef &key, String &x) const
 
const Json & operator[] (const StringRef &key) const
 Return the value at key in an object or array Json.
 
Json_object_proxy< Json > operator[] (const String &key)
 Return a proxy reference to the value at key in an object Json.
 
Json_object_str_proxy< Json > operator[] (const StringRef &key)
 
Json_object_str_proxy< Json > operator[] (const char *key)
 
const Json & at (const StringRef &key) const
 Return the value at key in an object Json.
 
Json & at_insert (const String &key)
 Return a reference to the value at key in an object Json.
 
Json & at_insert (const StringRef &key)
 
Json & at_insert (const char *key)
 
template<typename T >
Json & set (const String &key, T value)
 Set the value of key to value in this object Json.
 
Json & unset (const StringRef &key)
 Remove the value of key from an object Json.
 
Pair< object_iterator, bool > insert (const object_value_type &x)
 Insert element x in this object Json.
 
object_iterator insert (object_iterator position, const object_value_type &x)
 Insert element x in this object Json.
 
size_type erase (const StringRef &key)
 Remove the value of key from an object Json.
 
Json & merge (const Json &x)
 Merge the values of object Json x into this object Json.
 
template<typename P >
Json & merge (const Json_proxy_base< P > &x)
 
const Json & get (size_type x) const
 Return the x th array element.
 
Json & get_insert (size_type x)
 Return a reference to the x th array element.
 
const Json & operator[] (size_type x) const
 Return the x th array element.
 
Json_array_proxy< Json > operator[] (size_type x)
 Return a proxy reference to the x th array element.
 
const Json & at (size_type x) const
 Return the x th element in an array Json.
 
Json & at_insert (size_type x)
 Return a reference to the x th element in an array Json.
 
const Json & back () const
 Return the last array element.
 
Json & back ()
 Return a reference to the last array element.
 
template<typename T >
Json & push_back (T x)
 Push an element onto the back of the array.
 
void pop_back ()
 Remove the last element from an array.
 
const_object_iterator obegin () const
 
const_object_iterator oend () const
 
object_iterator obegin ()
 
object_iterator oend ()
 
const_object_iterator cobegin () const
 
const_object_iterator coend () const
 
const_array_iterator abegin () const
 
const_array_iterator aend () const
 
array_iterator abegin ()
 
array_iterator aend ()
 
const_array_iterator cabegin () const
 
const_array_iterator caend () const
 
const_iterator begin () const
 
const_iterator end () const
 
iterator begin ()
 
iterator end ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
String unparse () const
 Return the string representation of this Json.
 
String unparse (bool add_newline) const
 Return the string representation of this Json.
 
String unparse (const unparse_manipulator &m, bool add_newline=false) const
 Return the string representation of this Json.
 
void unparse (StringAccum &sa) const
 Unparse the string representation of this Json into sa.
 
void unparse (StringAccum &sa, const unparse_manipulator &m) const
 Unparse the string representation of this Json into sa.
 
bool assign_parse (const String &str)
 Parse str as UTF-8 JSON into this Json object.
 
bool assign_parse (const char *first, const char *last)
 Parse [first, last) as UTF-8 JSON into this Json object.
 
Json & operator= (const Json &x)
 
template<typename P >
Json & operator= (const Json_proxy_base< P > &x)
 
Json & operator++ ()
 
void operator++ (int)
 
Json & operator-- ()
 
void operator-- (int)
 
Json & operator+= (int x)
 
Json & operator+= (long x)
 
Json & operator+= (double x)
 
void swap (Json &x)
 Swap this Json with x.
 
 JsonStatics ()
 

Static Public Member Functions

static const Json & make_null ()
 
static Json make_array ()
 Return an empty array-valued Json.
 
static Json make_object ()
 Return an empty object-valued Json.
 
static Json make_string (const String &x)
 Return a string-valued Json.
 
static Json make_string (const char *s, int len)
 
static void static_initialize ()
 
static unparse_manipulator indent_depth (int x)
 
static unparse_manipulator tab_width (int x)
 
static Json parse (const String &str)
 Return str parsed as UTF-8 JSON.
 
static Json parse (const char *first, const char *last)
 Return [first, last) parsed as UTF-8 JSON.
 

Public Attributes

Json null_json
 
String array_string
 
String object_string
 

Detailed Description

Json data.

The Json class represents Json data: null values, booleans, numbers, strings, and combinations of these primitives into arrays and objects.

Json objects are not references, and two Json values cannot share subobjects. This differs from Javascript. For example:

Json j1 = Json::make_object(), j2 = Json::make_object(); j1.set("a", j2); // stores a COPY of j2 in j1 j2.set("b", 1); assert(j1.unparse() == "{\"a\":{}}"); assert(j2.unparse() == "{\"b\":1}");

Compare this with the Javascript code:

var j1 = {}, j2 = {}; j1.a = j2; // stores a REFERENCE to j2 in j1 j2.b = 1; assert(JSON.stringify(j1) == "{\"a\":{\"b\":1}}");

Most Json functions for extracting components and typed values behave liberally. For example, objects silently convert to integers, and extracting properties from non-objects is allowed. This should make it easier to work with untrusted objects. (Json objects often originate from untrusted sources, and may not have the types you expect.) If you prefer an assertion to fail when a Json object has an unexpected type, use the checked as_ and at functions, rather than the liberal to_, get, and operator[] functions.

Constructor & Destructor Documentation

◆ Json() [1/7]

Json::Json ( )
inline

Construct a null Json.

◆ Json() [2/7]

Json::Json ( const uninitialized_t &  unused)
inline

Construct an uninitialized timestamp.

◆ Json() [3/7]

Json::Json ( const Json &  x)
inline

Construct a Json copy of x.

◆ Json() [4/7]

Json::Json ( int  x)
inline

Construct simple Json values.

◆ Json() [5/7]

template<typename T >
Json::Json ( const Vector< T > &  x)
inline

Construct an array Json containing the elements of x.

◆ Json() [6/7]

template<typename T >
Json::Json ( T  first,
T  last 
)
inline

Construct an array Json containing the elements in [first, last).

◆ Json() [7/7]

template<typename T >
Json::Json ( const HashTable< String, T > &  x)
inline

Construct an object Json containing the values in x.

Member Function Documentation

◆ make_array()

Json Json::make_array ( )
inlinestatic

Return an empty array-valued Json.

◆ make_object()

Json Json::make_object ( )
inlinestatic

Return an empty object-valued Json.

◆ make_string() [1/2]

Json Json::make_string ( const String &  x)
inlinestatic

Return a string-valued Json.

◆ make_string() [2/2]

Json Json::make_string ( const char *  s,
int  len 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator unspecified_bool_type()

Json::operator unspecified_bool_type ( ) const
inline

Return true if this Json is not null.

See also
empty()

◆ operator!()

bool Json::operator! ( ) const
inline

Return true if this Json is null.

◆ type()

Json::json_type Json::type ( ) const
inline

Return this Json's type.

◆ is_null()

bool Json::is_null ( ) const
inline

Test this Json's type.

◆ is_primitive()

bool Json::is_primitive ( ) const
inline

Test if this Json is a primitive value, not including null.

◆ empty()

bool Json::empty ( ) const
inline

Return true if this Json is null, an empty array, or an empty object.

◆ size()

Json::size_type Json::size ( ) const
inline

Return the number of elements in this complex Json.

Precondition
is_array() || is_object() || is_null()

◆ to_i() [1/5]

long Json::to_i ( ) const
inline

Return this Json converted to an integer.

Converts any Json to an integer value. Numeric Jsons convert as you'd expect. Null Jsons convert to 0; false boolean Jsons to 0 and true boolean Jsons to 1; string Jsons to a number parsed from their initial portions; and array and object Jsons to size().

See also
as_i()

◆ to_u64()

uint64_t Json::to_u64 ( ) const
inline

Return this Json converted to a 64-bit unsigned integer.

See to_i() for the conversion rules.

◆ to_i() [2/5]

bool Json::to_i ( int &  x) const

Extract this integer Json's value into x.

Parameters
[out]xvalue storage
Returns
True iff this Json stores an integer value.

If false is returned (!is_number() or the number is not parseable as a pure integer), x remains unchanged.

◆ to_i() [3/5]

bool Json::to_i ( unsigned &  x) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_i() [4/5]

bool Json::to_i ( long &  x) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_i() [5/5]

bool Json::to_i ( unsigned long &  x) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ as_i()

long Json::as_i ( ) const
inline

Return the integer value of this numeric Json.

Precondition
is_number()
See also
to_i()

◆ to_d() [1/2]

double Json::to_d ( ) const

Return this Json converted to a double.

Converts any Json to an integer value. Numeric Jsons convert as you'd expect. Null Jsons convert to 0; false boolean Jsons to 0 and true boolean Jsons to 1; string Jsons to a number parsed from their initial portions; and array and object Jsons to size().

See also
as_d()

◆ to_d() [2/2]

bool Json::to_d ( double &  x) const
inline

Extract this numeric Json's value into x.

Parameters
[out]xvalue storage
Returns
True iff is_number().

If !is_number(), x remains unchanged.

◆ as_d()

double Json::as_d ( ) const
inline

Return the double value of this numeric Json.

Precondition
is_number()
See also
to_d()

◆ to_b() [1/2]

bool Json::to_b ( ) const
inline

Return this Json converted to a boolean.

Converts any Json to a boolean value. Boolean Jsons convert as you'd expect. Null Jsons convert to false; zero-valued numeric Jsons to false, and other numeric Jsons to true; empty string Jsons to false, and other string Jsons to true; and array and object Jsons to !empty().

See also
as_b()

◆ to_b() [2/2]

bool Json::to_b ( bool &  x) const
inline

Extract this boolean Json's value into x.

Parameters
[out]xvalue storage
Returns
True iff is_bool().

If !is_bool(), x remains unchanged.

◆ as_b()

bool Json::as_b ( ) const
inline

Return the value of this boolean Json.

Precondition
is_bool()
See also
to_b()

◆ to_s() [1/2]

const String & Json::to_s ( ) const
inline

Return this Json converted to a string.

Converts any Json to a string value. String Jsons convert as you'd expect. Null Jsons convert to the empty string; numeric Jsons to their string values; boolean Jsons to "false" or "true"; and array and object Jsons to "[Array]" and "[Object]", respectively.

See also
as_s()

◆ to_s() [2/2]

bool Json::to_s ( String &  x) const
inline

Extract this string Json's value into x.

Parameters
[out]xvalue storage
Returns
True iff is_string().

If !is_string(), x remains unchanged.

◆ as_s()

const String & Json::as_s ( ) const
inline

Return the value of this string Json.

Precondition
is_string()
See also
to_s()

◆ c_str()

const char * Json::c_str ( ) const
inline

Return to_s().c_str().

◆ count()

Json::size_type Json::count ( const StringRef &  key) const
inline

Return 1 if this object Json contains key, 0 otherwise.

Returns 0 if this is not an object Json.

◆ get() [1/10]

const Json & Json::get ( const StringRef &  key) const
inline

Return the value at key in an object or array Json.

If this is an array Json, and key is the simplest base-10 representation of an integer i, then returns get(i). If this is neither an array nor an object, returns a null Json.

◆ get_insert() [1/4]

Json & Json::get_insert ( const String &  key)
inline

Return a reference to the value of key in an object Json.

This Json is first converted to an object. Arrays are converted to objects with numeric keys. Other types of Json are converted to empty objects. If !count(key), then a null Json is inserted at key.

◆ get_insert() [2/4]

Json & Json::get_insert ( const StringRef &  key)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get_insert() [3/4]

Json & Json::get_insert ( const char *  key)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get_i()

long Json::get_i ( const StringRef &  key) const
inline

Return get(key).to_i().

◆ get_d()

double Json::get_d ( const StringRef &  key) const
inline

Return get(key).to_d().

◆ get_b()

bool Json::get_b ( const StringRef &  key) const
inline

Return get(key).to_b().

◆ get_s()

const String & Json::get_s ( const StringRef &  key) const
inline

Return get(key).to_s().

◆ get() [2/10]

const Json_get_proxy Json::get ( const StringRef &  key,
Json &  x 
) const
inline

Extract this object Json's value at key into x.

Parameters
[out]xvalue storage
Returns
proxy for *this

x is assigned iff contains(key). The return value is a proxy object that mostly behaves like *this. However, the proxy is "truthy" iff contains(key) and x was assigned. The proxy also has status() methods that return the extraction status. For example:

Json j = Json::parse("{\"a\":1,\"b\":2}"), x; assert(j.get("a", x)); // extraction succeeded assert(x == Json(1)); assert(!j.get("c", x)); // no "c" key assert(x == Json(1)); // x remains unchanged assert(!j.get("c", x).status()); // can use ".status()" for clarity

Can chain .get() methods to extract multiple values Json a, b, c; j.get("a", a).get("b", b); assert(a == Json(1) && b == Json(2));

Use .status() to return or assign extraction status bool a_status, b_status, c_status; j.get("a", a).status(a_status) .get("b", b).status(b_status) .get("c", c).status(c_status); assert(a_status && b_status && !c_status);

Overloaded versions of get() can extract integer, double, boolean, and string values for specific keys. These versions succeed iff contains(key) and the corresponding value has the expected type. For example:

Json j = Json::parse("{\"a\":1,\"b\":\"\"}"); int a, b; bool a_status, b_status; j.get("a", a).status(a_status).get("b", b).status(b_status); assert(a_status && a == 1 && !b_status);

◆ get() [3/10]

const Json_get_proxy Json::get ( const StringRef &  key,
int &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [4/10]

const Json_get_proxy Json::get ( const StringRef &  key,
unsigned &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [5/10]

const Json_get_proxy Json::get ( const StringRef &  key,
long &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [6/10]

const Json_get_proxy Json::get ( const StringRef &  key,
unsigned long &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [7/10]

const Json_get_proxy Json::get ( const StringRef &  key,
double &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [8/10]

const Json_get_proxy Json::get ( const StringRef &  key,
bool &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [9/10]

const Json_get_proxy Json::get ( const StringRef &  key,
String &  x 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [1/6]

const Json & Json::operator[] ( const StringRef &  key) const
inline

Return the value at key in an object or array Json.

See also
Json::get()

◆ operator[]() [2/6]

Json_object_proxy< Json > Json::operator[] ( const String &  key)
inline

Return a proxy reference to the value at key in an object Json.

Returns the current key value if it exists. Otherwise, returns a proxy that acts like a null Json. If this proxy is assigned, this Json is converted to an object as by get_insert(), and then extended as necessary to contain the new value.

◆ operator[]() [3/6]

Json_object_str_proxy< Json > Json::operator[] ( const StringRef &  key)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [4/6]

Json_object_str_proxy< Json > Json::operator[] ( const char *  key)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ at() [1/2]

const Json & Json::at ( const StringRef &  key) const
inline

Return the value at key in an object Json.

Precondition
is_object() && count(key)

◆ at_insert() [1/4]

Json & Json::at_insert ( const String &  key)
inline

Return a reference to the value at key in an object Json.

Precondition
is_object()

Returns a newly-inserted null Json if !count(key).

◆ at_insert() [2/4]

Json & Json::at_insert ( const StringRef &  key)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ at_insert() [3/4]

Json & Json::at_insert ( const char *  key)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ set()

template<typename T >
Json & Json::set ( const String &  key,
T  value 
)
inline

Set the value of key to value in this object Json.

Returns
this Json

An array Json is converted to an object Json with numeric keys. Other non-object Jsons are converted to empty objects.

◆ unset()

Json & Json::unset ( const StringRef &  key)
inline

Remove the value of key from an object Json.

Returns
this Json
See also
erase()

◆ insert() [1/2]

Pair< Json::object_iterator, bool > Json::insert ( const object_value_type &  x)
inline

Insert element x in this object Json.

Parameters
xPair of key and value.
Returns
Pair of iterator pointing to key's value and bool indicating whether the value is newly inserted.
Precondition
is_object()

An existing element with key x.first is not replaced.

◆ insert() [2/2]

Json::object_iterator Json::insert ( object_iterator  position,
const object_value_type &  x 
)
inline

Insert element x in this object Json.

Parameters
positionIgnored.
xPair of key and value.
Returns
Pair of iterator pointing to key's value and bool indicating whether the value is newly inserted.
Precondition
is_object()

An existing element with key x.first is not replaced.

◆ erase()

Json::size_type Json::erase ( const StringRef &  key)
inline

Remove the value of key from an object Json.

Precondition
is_object()
Returns
Number of items removed

◆ merge()

Json & Json::merge ( const Json &  x)
inline

Merge the values of object Json x into this object Json.

Precondition
(is_object() || is_null()) && (x.is_object() || x.is_null())
Returns
this Json

The key-value pairs in x are assigned to this Json. Null Jsons are silently converted to empty objects, except that if x and this Json are both null, then this Json is left as null.

◆ get() [10/10]

const Json & Json::get ( size_type  x) const
inline

Return the x th array element.

never

If x is out of range of this array, returns a null Json. If this is an object Json, then returns get(String(x)). If this is neither an object nor an array, returns a null Json.

◆ get_insert() [4/4]

Json & Json::get_insert ( size_type  x)
inline

Return a reference to the x th array element.

If this Json is an object, returns get_insert(String(x)). Otherwise this Json is first converted to an array; non-arrays are converted to empty arrays. The array is extended if x is out of range.

◆ operator[]() [5/6]

const Json & Json::operator[] ( size_type  x) const
inline

Return the x th array element.

If x is out of range of this array, returns a null Json. If this is an object Json, then returns get(String(x)). If this is neither an object nor an array, returns a null Json.

◆ operator[]() [6/6]

Json_array_proxy< Json > Json::operator[] ( size_type  x)
inline

Return a proxy reference to the x th array element.

If this Json is an object, returns operator[](String(x)). If this Json is an array and x is in range, returns that element. Otherwise, returns a proxy that acts like a null Json. If this proxy is assigned, this Json is converted to an array, and then extended as necessary to contain the new value.

◆ at() [2/2]

const Json & Json::at ( size_type  x) const
inline

Return the x th element in an array Json.

Precondition
is_array()

A null Json is treated like an empty array.

◆ at_insert() [4/4]

Json & Json::at_insert ( size_type  x)
inline

Return a reference to the x th element in an array Json.

Precondition
is_array()

The array is extended if x is out of range.

◆ back() [1/2]

const Json & Json::back ( ) const
inline

Return the last array element.

Precondition
is_array() && !empty()

◆ back() [2/2]

Json & Json::back ( )
inline

Return a reference to the last array element.

Precondition
is_array() && !empty()

◆ push_back()

template<typename T >
Json & Json::push_back ( T  x)
inline

Push an element onto the back of the array.

Precondition
is_array() || is_null()
Returns
this Json

A null Json is promoted to an array.

◆ pop_back()

void Json::pop_back ( )
inline

Remove the last element from an array.

Precondition
is_array() && !empty()

◆ unparse() [1/5]

String Json::unparse ( ) const
inline

Return the string representation of this Json.

◆ unparse() [2/5]

String Json::unparse ( bool  add_newline) const
inline

Return the string representation of this Json.

Parameters
add_newlineIf true, add a final newline.

◆ unparse() [3/5]

String Json::unparse ( const unparse_manipulator &  m,
bool  add_newline = false 
) const
inline

Return the string representation of this Json.

Parameters
add_newlineIf true, add a final newline.

◆ unparse() [4/5]

void Json::unparse ( StringAccum &  sa) const

Unparse the string representation of this Json into sa.

◆ unparse() [5/5]

void Json::unparse ( StringAccum &  sa,
const unparse_manipulator &  m 
) const
inline

Unparse the string representation of this Json into sa.

◆ assign_parse() [1/2]

bool Json::assign_parse ( const String &  str)
inline

Parse str as UTF-8 JSON into this Json object.

Returns
true iff the parse succeeded.

An unsuccessful parse does not modify *this.

◆ assign_parse() [2/2]

bool Json::assign_parse ( const char *  first,
const char *  last 
)
inline

Parse [first, last) as UTF-8 JSON into this Json object.

Returns
true iff the parse succeeded.

An unsuccessful parse does not modify *this.

◆ parse() [1/2]

Json Json::parse ( const String &  str)
inlinestatic

Return str parsed as UTF-8 JSON.

Returns a null JSON object if the parse fails.

◆ parse() [2/2]

Json Json::parse ( const char *  first,
const char *  last 
)
inlinestatic

Return [first, last) parsed as UTF-8 JSON.

Returns a null JSON object if the parse fails.

◆ operator++()

Json & Json::operator++ ( )
inline

never

◆ swap()

void Json::swap ( Json &  x)
inline

Swap this Json with x.


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