Here are the 8 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.

StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json);
const char* sensor = root["sensor"];
long time = root["time"];
double latitude = root["data"][0];
double longitude = root["data"][1];
View JsonParserExample.ino
JSON Generator

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

StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["sensor"] = "gps";
root["time"] = 1351824120;
root.printTo(Serial);
View JsonGeneratorExample.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);
JsonObject& root = jsonBuffer.parseObject(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);
root.printTo(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();
root.prettyPrintTo(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);
JsonObject &root = jsonBuffer.parseObject(file)
file.close();

config.port = root["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