| sajson
    High-Performance JSON Parser | 
Represents a JSON value. More...
#include <sajson.h>
| Public Member Functions | |
| type | get_type () const | 
| Returns the JSON value's type.  More... | |
| size_t | get_length () const | 
| Returns the length of the object or array.  More... | |
| value | get_array_element (size_t index) const | 
| Returns the nth element of an array.  More... | |
| string | get_object_key (size_t index) const | 
| Returns the nth key of an object.  More... | |
| value | get_object_value (size_t index) const | 
| Returns the nth value of an object.  More... | |
| value | get_value_of_key (const string &key) const | 
| Given a string key, returns the value with that key or a null value if the key is not found.  More... | |
| size_t | find_object_key (const string &key) const | 
| Given a string key, returns the index of the associated value if one exists.  More... | |
| int | get_integer_value () const | 
| If a numeric value was parsed as a 32-bit integer, returns it.  More... | |
| double | get_double_value () const | 
| If a numeric value was parsed as a double, returns it.  More... | |
| double | get_number_value () const | 
| Returns a numeric value as a double-precision float.  More... | |
| bool | get_int53_value (int64_t *out) const | 
| Returns true and writes to the output argument if the numeric value fits in a 53-bit integer.  More... | |
| size_t | get_string_length () const | 
| Returns the length of the string.  More... | |
| const char * | as_cstring () const | 
| Returns a pointer to the beginning of a string value's data.  More... | |
| std::string | as_string () const | 
| Returns a string's value as a std::string.  More... | |
| 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.
| 
 | inline | 
Returns the length of the object or array.
Only legal if get_type() is TYPE_ARRAY or 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 | 
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.
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.
| 
 | 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 | 
If a numeric value was parsed as a 32-bit integer, returns it.
Only legal if get_type() is TYPE_INTEGER.
| 
 | inline | 
If a numeric value was parsed as a double, returns it.
Only legal if get_type() is TYPE_DOUBLE.
| 
 | inline | 
Returns a numeric value as a double-precision float.
Only legal if get_type() is TYPE_INTEGER or 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 | 
Returns the length of the string.
Only legal if get_type() is TYPE_STRING.
| 
 | 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.
 1.8.11
 1.8.11