mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-20 04:52:38 +02:00
Updated API Reference (markdown)
@@ -8,7 +8,7 @@ Represents an array in a JSON object tree.
|
||||
|
||||
The constructor is private, you cannot instanciate a `JsonArray` directly, you have to use a `JsonBuffer`.
|
||||
|
||||
Because the actual memory location of a `JsonArray` is in the `JsonBuffer`, you always manipulate them through reference and you cannot copy them.
|
||||
Because the memory of a `JsonArray` is located a `JsonBuffer`, you always manipulate it through reference and you cannot copy it.
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -78,24 +78,41 @@ will write
|
||||
["hello",3.1416]
|
||||
```
|
||||
|
||||
#### JsonArray::get()
|
||||
### JsonArray::get()
|
||||
|
||||
##### Description
|
||||
Gets the value at the specified index.
|
||||
|
||||
##### Signatures
|
||||
##### Signature
|
||||
```c++
|
||||
JsonVariant get(size_t index)
|
||||
JsonVariant get(size_t index) const
|
||||
T get<T>(size_t index) const;
|
||||
```
|
||||
|
||||
##### Arguments
|
||||
`index`
|
||||
|
||||
`index`: the index of the the value in the array.
|
||||
|
||||
`T`: the type of the value
|
||||
|
||||
##### Return value
|
||||
|
||||
The value at the specified index. This can be a `JsonVariant` or a value of type T.
|
||||
|
||||
The template version of `get()` returns a value of the specified type.
|
||||
In case of an error (index out of range or incompatible type), the default value of the type `T` is returned.
|
||||
|
||||
##### Example
|
||||
```c++
|
||||
char json[] = "[1,3.14]";
|
||||
StaticJsonBuffer<256> jsonBuffer;
|
||||
JsonArray& array = jsonBuffer.parseArray(json);
|
||||
int value0 = array.get(0); // implicit cast of the JsonVariant
|
||||
float value1 = array.get<float>(1); // template version of get()
|
||||
const char* value2 = array.get(2); // returns NULL
|
||||
```
|
||||
#### JsonArray::operator[]
|
||||
|
||||
### JsonArray::operator[]
|
||||
|
||||
##### Description
|
||||
##### Signatures
|
||||
|
Reference in New Issue
Block a user