Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsJul 14, 2026·2 min de lectura

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.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
ArduinoJson
Comando de instalación directa
npx -y tokrepo@latest install 7249eb89-7f83-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con 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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados