Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 14, 2026·2 min de lecture

ArduinoJson — Fast JSON Library for Embedded C++

ArduinoJson is a memory-efficient JSON library for Arduino, ESP32, and embedded C++ projects. It handles parsing, serialization, and MessagePack with a zero-copy design optimized for constrained devices.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
ArduinoJson
Commande d'installation directe
npx -y tokrepo@latest install 7249eb89-7f83-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

ArduinoJson is a C++ JSON library designed for embedded systems. It provides a simple API for parsing and generating JSON with predictable memory usage, making it the standard choice for IoT firmware that communicates via JSON APIs.

What ArduinoJson Does

  • Parses JSON strings into a queryable document model
  • Serializes C++ data structures to JSON or MessagePack
  • Uses a fixed-size or dynamic memory pool to avoid heap fragmentation
  • Supports JSON filtering to parse only the fields you need
  • Handles nested objects, arrays, and streaming input

Architecture Overview

ArduinoJson uses a JsonDocument that owns a contiguous memory pool. Parsing writes all values into this pool, avoiding scattered heap allocations. The library is header-only with no external dependencies, compiling on any C++11 toolchain from AVR to 64-bit desktop.

Self-Hosting & Configuration

  • Install via the Arduino Library Manager or PlatformIO
  • Include the single header and create a JsonDocument with a size estimate
  • Use the ArduinoJson Assistant at arduinojson.org to calculate memory requirements
  • Configure stack vs heap allocation by choosing StaticJsonDocument or DynamicJsonDocument
  • Works on Arduino, ESP8266, ESP32, STM32, Teensy, and standard Linux/macOS/Windows

Key Features

  • Header-only with zero external dependencies
  • Predictable memory usage with no fragmentation
  • Supports both JSON and MessagePack binary format
  • JSON filtering reduces memory use by skipping unneeded fields
  • Extensive test suite with over 3,000 unit tests

Comparison with Similar Tools

  • cJSON — plain C and smaller but lacks type safety and streaming; ArduinoJson is more ergonomic in C++
  • RapidJSON — faster on desktop but uses more memory; ArduinoJson is optimized for MCUs
  • nlohmann/json — beautiful API for desktop C++; too large for most embedded targets
  • Jansson — C library with good API but no MessagePack support

FAQ

Q: How much RAM does ArduinoJson need? A: It depends on the document. A typical IoT payload with 5-10 fields uses 200-500 bytes. The online assistant calculates exact requirements.

Q: Does it work on 8-bit AVR boards? A: Yes. ArduinoJson supports AVR, ARM, RISC-V, and Xtensa architectures with as little as 2KB RAM.

Q: Can I parse streaming JSON? A: Yes. ArduinoJson can read from Stream objects (Serial, WiFiClient, File) without loading the entire string into memory.

Q: Is ArduinoJson free for commercial use? A: Yes. It is released under the MIT license.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires