Skip to content

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.

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.
ParameterTypeDefaultDescription
pathstring—Path of the JSON file.

None.

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"]).

MessageCause 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.
Read JSON path = asset("config.json") → output: config
Set 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"]