|
JsoNeat
Some JSON parse/iterate C++ classes build on top of Jsmn
|
This has iterator functionality, but also provides lots of token related member functions. More...
#include </home/bertw/proj/mcu/libs/mbed-jsoneat/components/jsoneat/include/jsoneat/jsoneat.hh>
Public Types | |
| using | iterator_category = std::forward_iterator_tag |
| using | difference_type = std::ptrdiff_t |
| using | value_type = jsmntok_t |
| using | pointer = value_type * |
| using | reference = value_type & |
| using | container_type = JsoNeat |
Public Member Functions | |
| Iterator (pointer ptr, container_type &container) | |
| bool | value_st_equal (const char *s, jsmntype_t type) const |
| Test type and character string of value for being equal. | |
| bool | value_equals_null () const |
| test for value being null pointer | |
| bool | value_equals_false () const |
| test for value being boolean false | |
| bool | value_equals_true () const |
| test for value being boolean true | |
| input_type | get_json () |
| get json text buffer | |
| bool | keyIsEqual (const char *key) const |
| test if key matches | |
| bool | keyIsEqual (const char *key, jsmntype_t val_type) const |
| test if both key and value-type matches | |
| bool | keyStartsWith (const char *key) const |
| test if key matches | |
| bool | keyStartsWith (const char *key, jsmntype_t val_type) const |
| test if both key and value-type matches | |
| template<typename T > | |
| bool | getValue (T &dst) const |
| Get value. | |
| template<typename T > | |
| bool | takeValue (T &dst) |
| Get value of key/value pair and advance iterator. | |
| template<size_t size> | |
| bool | getValueAsString (char(&dst)[size]) const |
| Get value as string instead of number or boolean. | |
| bool | getValueAsString (char *dst, size_t size) const |
| Get value as string instead of number or boolean. | |
| char * | getValueAsString () const |
| Get value as string null terminated string (in place) | |
| template<typename T > | |
| bool | getValue (T &dst, const char *key) const |
| Get value of key/value pair if key. | |
| template<typename T > | |
| bool | takeValue (T &dst, const char *key) |
| Get value of key/value pair and advance iterator. | |
| template<typename T , std::size_t N> | |
| bool | takeValueArray (T(&dst)[N], const char *key) |
| Get values from array and advance iterator. | |
| template<typename T > | |
| bool | takeObject (T &dst, const char *key) |
| Get object of key/value pair and advance iterator. | |
| template<typename T , size_t N> | |
| bool | takeObjectArray (T(&dst)[N], const char *key) |
| Get objects from array and advance iterator. | |
| template<typename T , size_t N> | |
| bool | takeObjectArray (std::array< T, N > &dst, const char *key) |
| Get objects from array and advance iterator. | |
| reference | operator* () const |
| pointer | operator-> () |
| Iterator | operator+ (int n) |
| Iterator | operator- (int n) |
| Iterator & | operator+= (int n) |
| Iterator & | operator-= (int n) |
| Iterator & | operator++ () |
| Iterator | operator++ (int) |
| reference | operator[] (int idx) |
| operator bool () const | |
| bool | skip_value () |
| skip this value (of an array) | |
| bool | skip_key_and_value () |
| skip this key/value pair (in and object) | |
| bool | skip_key () |
| skip this key | |
Friends | |
| bool | operator== (const Iterator &a, const Iterator &b) |
| bool | operator!= (const Iterator &a, const Iterator &b) |
| bool | operator< (const Iterator &a, const Iterator &b) |
| bool | operator> (const Iterator &a, const Iterator &b) |
This has iterator functionality, but also provides lots of token related member functions.
With Jsmn, the token holds indexes of the original JSON buffer. Like a normal iterator, this struct holds a pointer to the token, which is an element of \ref m_tok_arr To access the actual JSON data (\ref m_json in class \ref JsoNeat), \ref m_container in this struct holds a references, which then can also be used to call member functions of JsoNeat object.
|
inline |
Get value.
| dst | value will be written to dst |
|
inline |
Get value of key/value pair if key.
| key | key to match or nullptr to match any key |
| dst | value will be written to dst |
|
inline |
Get value as string null terminated string (in place)
This works only for non constant input_type, because it writes
into the json text buffer to terminate strings.
|
inline |
Get value as string instead of number or boolean.
| dst | value will be written to dst |
| size | space available in dst |
|
inline |
Get value as string instead of number or boolean.
| dst | value will be written to dst |
|
inline |
test if key matches
| key | key to match |
|
inline |
test if both key and value-type matches
| key | string to match key or nullptr to match any key |
| val_type | type of value to match |
|
inline |
test if key matches
| key | key to match |
|
inline |
test if both key and value-type matches
| key | string to match key or nullptr to match any key |
| val_type | type of value to match |
|
inline |
skip this key
|
inline |
skip this key/value pair (in and object)
|
inline |
skip this value (of an array)
|
inline |
Get object of key/value pair and advance iterator.
| key | key to match or nullptr to match any key |
| dst | object will be written to dst |
|
inline |
Get objects from array and advance iterator.
| T | type of array members |
| N | array_size |
| key | key to match or nullptr to match any key |
| dst | objects will be written to array dst |
|
inline |
Get objects from array and advance iterator.
| T | type of array members |
| N | array_size |
| key | key to match or nullptr to match any key |
| dst | objects will be written to array dst |
|
inline |
Get value of key/value pair and advance iterator.
| dst | value will be written to dst |
|
inline |
Get value of key/value pair and advance iterator.
| key | key to match or nullptr to match any key |
| dst | value will be written to dst |
|
inline |
Get values from array and advance iterator.
| T | type of array members |
| N | array_size |
| key | key to match or nullptr to match any key |
| dst | values will be written to array dst |
|
inline |
test for value being boolean false
|
inline |
test for value being null pointer
|
inline |
test for value being boolean true
|
inline |
Test type and character string of value for being equal.
| s | expected string |
| type | expected type |