Overview
The json-parser node converts between JSON strings and
JavaScript objects. Use it to parse incoming JSON text from APIs, serial devices, and files
into usable objects, or to stringify objects back into JSON for transmission and storage.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| action | string | "parse" | "parse" (string → object) or "stringify" (object → string) |
| property | string | "payload" | Source property to parse or stringify |
| target | string | "payload" | Target property where the result is stored |
Actions
parse
Convert a JSON string into a JavaScript object
Input: msg.payload.data = '{"temp":23.5}'
Output: msg.payload.data = { temp: 23.5 } stringify
Convert a JavaScript object into a JSON string
Input: msg.payload.data = { temp: 23.5 }
Output: msg.payload.data = '{"temp":23.5}' Example: Parse API Response
Parse a JSON string received from an HTTP request into a usable object.
// json-parser node configuration
{
"action": "parse",
"property": "payload",
"target": "payload"
}
// Input from HTTP request node:
{
"payload": {
"data": "{\"status\":\"ok\",\"temperature\":23.5,\"humidity\":65}"
}
}
// Output after parsing:
{
"payload": {
"data": {
"status": "ok",
"temperature": 23.5,
"humidity": 65
}
}
}
// Flow: [http-request] → [json-parser] → [switch on status] Example: Parse Serial JSON Data
Parse JSON strings received from an Arduino over serial into structured data.
// json-parser node configuration
{
"action": "parse"
}
// Arduino sends: {"temp":23.5,"humidity":65,"sensor":"dht22"}
// serial-in receives as string in msg.payload.data
// After json-parser:
{
"payload": {
"data": {
"temp": 23.5,
"humidity": 65,
"sensor": "dht22"
}
}
}
// Flow: [serial-in] → [json-parser] → [set node] → [dashboard] Example: Stringify for MQTT Publish
Convert an object to a JSON string before publishing to an MQTT topic.
// json-parser node configuration
{
"action": "stringify"
}
// Input from function node:
{
"payload": {
"data": {
"device": "sensor-01",
"temperature": 23.5,
"timestamp": 1700000000
}
}
}
// Output after stringify:
{
"payload": {
"data": "{\"device\":\"sensor-01\",\"temperature\":23.5,\"timestamp\":1700000000}"
}
}
// Flow: [function build obj] → [json-parser stringify] → [mqtt-out] Common Use Cases
API Response Parsing
Parse JSON responses from REST APIs and webhooks
Serial Device Data
Parse JSON from Arduino, ESP32, and other serial devices
MQTT Payloads
Parse or stringify MQTT message payloads
File Processing
Parse JSON files or prepare data for JSON file output