This class provides a fluent-style API for easily traversing a tree of JSON objects to find a value.
More...
#include <JsonParserGeneratorRK.h>
|
| JsonReference (const JsonParser *parser) |
| Constructs an object. Normally you use the JsonParser getReference() method to get one of these instead of constructing one. More...
|
|
virtual | ~JsonReference () |
| Destructor. This does not affect the lifecycle of the JsonParser.
|
|
| JsonReference (const JsonParser *parser, const JsonParserGeneratorRK::jsmntok_t *token) |
| Constructs are JsonReference for a specific token within a JsonParser.
|
|
JsonReference | key (const char *name) const |
| For JsonReference that refers to a JSON object, gets a new JsonReference to a value with the specified key name. More...
|
|
JsonReference | index (size_t index) const |
| For a JsonReference that refers to a JSON array, gets a new JsonReference to a value in the array by index. More...
|
|
size_t | size () const |
| For a JsonReference that refers to a JSON array, gets the size of the array. More...
|
|
template<class T > |
bool | value (T &result) const |
| Get a value of the specified type for a given value for a specified key, or index for an array. More...
|
|
bool | valueBool (bool defaultValue=false) const |
| Returns a boolean (bool) value for an object value for key, or array index. More...
|
|
int | valueInt (int defaultValue=0) const |
| Returns a integer (int) value for an object value for key, or array index. More...
|
|
unsigned long | valueUnsignedLong (unsigned long defaultValue=0) const |
| Returns a unsigned long integer for an object value for key, or array index. More...
|
|
float | valueFloat (float defaultValue=0.0) const |
| Returns a float value for an object value for key, or array index. More...
|
|
double | valueDouble (double defaultValue=0.0) const |
| Returns a double value for an object value for key, or array index. More...
|
|
String | valueString () const |
| Returns a String value for an object value for key, or array index. More...
|
|
This class provides a fluent-style API for easily traversing a tree of JSON objects to find a value.
◆ JsonReference()
JsonReference::JsonReference |
( |
const JsonParser * |
parser | ) |
|
Constructs an object. Normally you use the JsonParser getReference() method to get one of these instead of constructing one.
- Parameters
-
◆ index()
For a JsonReference that refers to a JSON array, gets a new JsonReference to a value in the array by index.
- Parameters
-
index | The index to retrieve (0 = first item, 1 = second item, ...). |
- Returns
- A JsonReference to the value for this index.
◆ key()
For JsonReference that refers to a JSON object, gets a new JsonReference to a value with the specified key name.
- Parameters
-
name | of the key to look for. |
- Returns
- A JsonReference to the value for this key.
◆ size()
size_t JsonReference::size |
( |
| ) |
const |
For a JsonReference that refers to a JSON array, gets the size of the array.
- Returns
- 0 = an empty array, 1 = one element, ...
◆ value()
template<class T >
bool JsonReference::value |
( |
T & |
result | ) |
const |
|
inline |
Get a value of the specified type for a given value for a specified key, or index for an array.
- Parameters
-
result | Filled in with the value. The value can be of type: bool, int, unsigned long, float, double, String, or (char *, size_t&). |
There are also type-specific versions like valueBool that return the value, instead of having to pass an object to hold the value, as in this call.
◆ valueBool()
bool JsonReference::valueBool |
( |
bool |
defaultValue = false | ) |
const |
Returns a boolean (bool) value for an object value for key, or array index.
- Parameters
-
defaultValue | Optional value to use if the key or array index is not found. Default: false. |
◆ valueDouble()
double JsonReference::valueDouble |
( |
double |
defaultValue = 0.0 | ) |
const |
Returns a double value for an object value for key, or array index.
- Parameters
-
defaultValue | Optional value to use if the key or array index is not found. Default: 0.0. |
◆ valueFloat()
float JsonReference::valueFloat |
( |
float |
defaultValue = 0.0 | ) |
const |
Returns a float value for an object value for key, or array index.
- Parameters
-
defaultValue | Optional value to use if the key or array index is not found. Default: 0.0. |
◆ valueInt()
int JsonReference::valueInt |
( |
int |
defaultValue = 0 | ) |
const |
Returns a integer (int) value for an object value for key, or array index.
- Parameters
-
defaultValue | Optional value to use if the key or array index is not found. Default: 0. |
◆ valueString()
String JsonReference::valueString |
( |
| ) |
const |
Returns a String value for an object value for key, or array index.
- Returns
- The string value, or an empty string if the key or array index is not found.
◆ valueUnsignedLong()
unsigned long JsonReference::valueUnsignedLong |
( |
unsigned long |
defaultValue = 0 | ) |
const |
Returns a unsigned long integer for an object value for key, or array index.
- Parameters
-
defaultValue | Optional value to use if the key or array index is not found. Default: 0. |
The documentation for this class was generated from the following files: