Here are the 9 official examples of ArduinoJson. They are available in the "Examples" menu of the Arduino IDE.

JSON Parser

This example shows how to deserialize a JSON document with ArduinoJson.

deserializeJson(doc, input);
const char* sensor = doc["sensor"];
long time = doc["time"];
double latitude = doc["data"][0];
double longitude = doc["data"][1];
View JsonParserExample.ino
JSON Generator

This example shows how to generate a JSON document with the ArduinoJson library.

StaticJsonDocument<200> doc;
doc["sensor"] = "gps";
doc["time"] = 1351824120;
serializeJson(doc, Serial);
View JsonGeneratorExample.ino
MessagePack parser

This example shows how to parse a MessagePack input with ArduinoJson.

deserializeMsgPack(doc, input);
const char* sensor = doc["sensor"];
long time = doc["time"];
double latitude = doc["data"][0];
double longitude = doc["data"][1];
View MsgPackParser.ino
JSON HTTP Client

This example shows how to parse a JSON document in an HTTP response. It uses the Ethernet library, but can be easily adapted for Wifi.

client.println(F("GET /example.json HTTP/1.0"));
client.println(F("Connection: close"));
client.println();
client.find(endOfHeaders);
deserializeJson(doc, client);
View JsonHttpClient.ino
JSON UDP Beacon

This example shows how to send a JSON document to a UDP socket. It uses the Ethernet library but could easily be changed to support Wifi.

udp.beginPacket(remoteIp, remotePort);
serializeJson(doc, udp);
udp.println();
udp.endPacket();
View JsonUdpBeacon.ino
JSON HTTP Server

This example shows how to implement an HTTP server that sends JSON document in the responses.

client.println("HTTP/1.0 200 OK");
client.println("Content-Type: application/json");
client.println();
serializeJsonPretty(doc, client);
client.stop();
View JsonServer.ino
JSON Configuration File

This example shows how to store your project configuration in a file. It uses the SD library but can be easily modified for any other file-system.

File file = SD.open(filename);
deserializeJson(doc, file);
file.close();

config.port = doc["port"] | 2731;
View JsonConfigFile.ino
String objects and ArduinoJson

This example shows the different ways you can use String objects with ArduinoJson.

long time = obj[String("time")];
obj[String("time")] = time;
String sensor = obj["sensor"];
sensor = obj["sensor"].as<String>();
View StringExample.ino
Flash strings and ArduinoJson

This example shows the different ways you can use Flash strings (`PROGMEM`) with ArduinoJson.

long time = obj[F("time")];
obj[F("time")] = time;
obj["sensor"] = F("gps");
obj["sensor"] = serialized(F("\"gps\""));
View ProgmemExample.ino