Read JSON
Read JSON
Section titled “Read JSON”Type: read-json · Package: JSON Activities v1.0.4 · Output: object
Reads a JSON file and returns its content already structured: a dictionary (object) or a list (array), navigable by keys and indexes. You don’t need to parse any text: the result is ready to use.
How it works
Section titled “How it works”Reads the file at path, parses its JSON and returns the structure. Then you access the data with expressions: data["key"], list[0], data["items"][0]["name"].
- Strict format: the file must be valid JSON. Comments (
//), trailing commas and single quotes are not accepted. - Encoding: UTF-8 (UTF-16/UTF-32 are also recognized when the file has a BOM).
- Value conversion: objects → dictionary, arrays → list, integers →
long, decimals →double. See how values are converted. - Read-only: the file is not changed. It is loaded fully into memory.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the JSON file. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns an object whose type depends on the JSON root:
{ … }→ dictionary (Dictionary) with text keys.[ … ]→ list (List).- A single value (
"text",42,true) → that value.
Reading a key that does not exist returns an empty value, not an error: check it with isNull(config["key"]).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
File not found. | path does not exist. Check it with File Exists. |
'…' is an invalid start of a value. LineNumber: … | BytePositionInLine: …. (or another system JSON error) | The content is not valid JSON: comments, trailing commas, single quotes or non-JSON text. The message gives the line and position. Fix the file. |
The input does not contain any JSON tokens… | The file is empty. |
The file does not contain valid JSON. | The file contains only null. |
'path' is required. | The path expression evaluated to null. |
Example
Section titled “Example”Read JSON path = asset("config.json") → output: configSet Variable name = outputFolder value = config["outputFolder"]Log message = "First item: " + str(config["items"][0]["name"])
For Each items = config["items"] itemVariable = item └─ activities: Log message = "Processing " + item["name"]Related activities
Section titled “Related activities”- Write JSON — save a value as JSON.
- HTTP GET — receive JSON from an API.