#include <Ultralight/JSON.h>
A view of a JSON array.
Calling JSON::AsArray() on a JSON value returns a JSONArray view. You use it to step through array elements in a range-for loop and append new values.
This example appends values to an array and logs each element:
for (
JSON score : entries)
Log(score.Stringify().utf8().data());
friend class JSON
Definition JSON.h:904
JSONArray(const JSONArray &other)
Copy constructor.
void Push(const JSON &value)
Append value, sharing its document.
JSONArray AsArray() const
Get a typed view of this value as an array (for iteration, size(), and Push()).
static JSON Array()
Create a new empty array value.
Elements and Appending
Iterating over the array yields each element as a JSON that shares the underlying document.
Calling JSON::AsArray() on a value that isn't an array returns an empty view. The loop doesn't run, and Push() does nothing.
- See also
- JSON::AsArray(), JSONObject
|
| | JSONArray (const JSONArray &other) |
| | Copy constructor.
|
| | ~JSONArray () |
| | Destructor.
|
| size_t | size () const |
| | Get the number of elements (0 for an empty view).
|
| void | Push (const JSON &value) |
| | Append value, sharing its document.
|
| void | Push (bool value) |
| | Append a boolean.
|
| void | Push (double value) |
| | Append a number.
|
| void | Push (int value) |
| | Append a number.
|
| void | Push (unsigned value) |
| | Append a number.
|
| void | Push (long value) |
| | Append a number.
|
| void | Push (unsigned long value) |
| | Append a number.
|
| void | Push (long long value) |
| | Append a number.
|
| void | Push (unsigned long long value) |
| | Append a number.
|
| void | Push (const String &value) |
| | Append a string.
|
| void | Push (const char *value) |
| | Append a string.
|
| void | Push (decltype(nullptr)) |
| | Append a JSON null.
|
| iterator | begin () const |
| | Get an iterator to the first element.
|
| iterator | end () const |
| | Get an iterator past the last element.
|
◆ JSONArray()
| JSONArray |
( |
const JSONArray & | other | ) |
|
◆ ~JSONArray()
◆ begin()
Get an iterator to the first element.
◆ end()
Get an iterator past the last element.
◆ Push() [1/12]
◆ Push() [2/12]
| void Push |
( |
const char * | value | ) |
|
◆ Push() [3/12]
| void Push |
( |
const JSON & | value | ) |
|
Append value, sharing its document.
- Note
- An invalid value appends nothing.
◆ Push() [4/12]
| void Push |
( |
const String & | value | ) |
|
◆ Push() [5/12]
| void Push |
( |
decltype(nullptr) | | ) |
|
◆ Push() [6/12]
| void Push |
( |
double | value | ) |
|
◆ Push() [7/12]
◆ Push() [8/12]
| void Push |
( |
long long | value | ) |
|
◆ Push() [9/12]
◆ Push() [10/12]
| void Push |
( |
unsigned long long | value | ) |
|
◆ Push() [11/12]
| void Push |
( |
unsigned long | value | ) |
|
◆ Push() [12/12]
| void Push |
( |
unsigned | value | ) |
|
◆ size()
Get the number of elements (0 for an empty view).
◆ JSON
The documentation for this class was generated from the following file: