#include <sajson.h>
Public Member Functions | |
const char * | as_cstring () const |
std::string | as_string () const |
size_t | find_object_key (const string &key) const |
value | get_array_element (size_t index) const |
double | get_double_value () const |
bool | get_int53_value (int64_t *out) const |
int | get_integer_value () const |
size_t | get_length () const |
double | get_number_value () const |
string | get_object_key (size_t index) const |
value | get_object_value (size_t index) const |
size_t | get_string_length () const |
type | get_type () const |
Returns the JSON value's type. More... | |
value | get_value_of_key (const string &key) const |
Private Member Functions | |
void | assert_in_bounds (size_t i) const |
void | assert_type (type expected) const |
void | assert_type_2 (type e1, type e2) const |
value (type value_type_, const size_t *payload_, const char *text_) | |
Private Attributes | |
const size_t *const | payload |
const char *const | text |
const type | value_type |
Friends | |
class | document |
Represents a JSON value. First, call get_type() to check its type, which determines which methods are available.
Note that value does not maintain any backing memory, only the corresponding document does. It is illegal to access a value after its document has been destroyed.
|
inlineexplicitprivate |
|
inline |
Returns a pointer to the beginning of a string value's data. WARNING: Calling this function and using the return value as a C-style string (that is, without also using get_string_length()) will cause the string to appear truncated if the string has embedded NULs. Only legal if get_type() is TYPE_STRING.
|
inline |
Returns a string's value as a std::string. Only legal if get_type() is TYPE_STRING.
|
inlineprivate |
|
inline |
Given a string key, returns the index of the associated value if one exists. Returns get_length() if there is no such key. Note: sajson sorts object keys, so the running time is O(lg N). Only legal if get_type() is TYPE_OBJECT
|
inline |
Returns the nth element of an array. Calling with an out-of-bound index is undefined behavior. Only legal if get_type() is TYPE_ARRAY.
|
inline |
If a numeric value was parsed as a double, returns it. Only legal if get_type() is TYPE_DOUBLE.
|
inline |
Returns true and writes to the output argument if the numeric value fits in a 53-bit integer. This is useful for timestamps and other situations where integral values with greater than 32-bit precision are used, as 64-bit values are not understood by all JSON implementations or languages. Returns false if the value is not an integer or not in range. Only legal if get_type() is TYPE_INTEGER or TYPE_DOUBLE.
|
inline |
If a numeric value was parsed as a 32-bit integer, returns it. Only legal if get_type() is TYPE_INTEGER.
|
inline |
Returns the length of the object or array. Only legal if get_type() is TYPE_ARRAY or TYPE_OBJECT.
|
inline |
Returns a numeric value as a double-precision float. Only legal if get_type() is TYPE_INTEGER or TYPE_DOUBLE.
|
inline |
Returns the nth key of an object. Calling with an out-of-bound index is undefined behavior. Only legal if get_type() is TYPE_OBJECT.
|
inline |
Returns the nth value of an object. Calling with an out-of-bound index is undefined behavior. Only legal if get_type() is TYPE_OBJECT.
|
inline |
Returns the length of the string. Only legal if get_type() is TYPE_STRING.
|
inline |
Given a string key, returns the value with that key or a null value if the key is not found. Running time is O(lg N). Only legal if get_type() is TYPE_OBJECT.