mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-09-26 06:50:56 +02:00
Updated Bag of Tricks (markdown)
@@ -1,5 +1,29 @@
|
|||||||
Here are helper class that can help you add missing features.
|
Here are helper class that can help you add missing features.
|
||||||
|
|
||||||
|
## Extract an array of integer
|
||||||
|
|
||||||
|
Suppose we have an input like this:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"leds":[56,60,46]}
|
||||||
|
```
|
||||||
|
|
||||||
|
And we want to get a `int[]` out of it:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
#define MAX_LED_COUNT 10
|
||||||
|
|
||||||
|
int leds[MAX_LED_COUNT];
|
||||||
|
int ledCount = 0;
|
||||||
|
|
||||||
|
for(int led : root["leds"].asArray()) {
|
||||||
|
leds[ledCount++] = led;
|
||||||
|
if (ledCount >= MAX_LED_COUNT) break;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
See issue [#246](https://github.com/bblanchon/ArduinoJson/issues/246)
|
||||||
|
|
||||||
## Buffered output:
|
## Buffered output:
|
||||||
|
|
||||||
Here is a proxy that will put bytes in a buffer before actually writing them to the destination:
|
Here is a proxy that will put bytes in a buffer before actually writing them to the destination:
|
||||||
|
Reference in New Issue
Block a user