Write JSON
Write JSON
Section titled “Write JSON”Type: write-json · Package: JSON Activities v1.0.4 · Output: string
Converts a value (a dictionary, a list, a table) to JSON and saves it to a file. Useful to produce settings files, export data or leave a summary another system can read.
How it works
Section titled “How it works”Serializes value to JSON and writes it to path. By default it formats the result for readability (indented = true). Returns the written path.
- What gets converted: dictionaries → objects, lists → arrays, texts, numbers, booleans and dates (ISO 8601,
2026-10-15T08:30:00). A DataTable is saved as an array of objects, one per row (column → value; empty cells →null). A null value writesnull. - Special characters: accented letters and characters such as
<,>or&are saved as\u00E1-style sequences. It is valid JSON and any reader (including Read JSON) gets them back unchanged. - File: written as UTF-8 without BOM. If it exists, it is replaced; if the folder does not exist, it is created.
- Idempotent: repeating it with the same value leaves the same file.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the output JSON file, including its folder. |
value | object | — | The value to convert: dictionary, list, DataTable, text, number… |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
indented | bool | true | Format with line breaks and indentation so it is easy to read. With false, everything goes on one line (smaller file). |
Output
Section titled “Output”Returns a string with the path of the written file (as you gave it in path).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
The process cannot access the file '…' because it is being used by another process. | The file is open in another program. |
Access to the path '…' is denied. | No write permission on the folder. |
'path' is required. | The path expression evaluated to null. |
If path has no folder (just a file name), the activity fails: use a full path. Values of special types (for example a single DataRow or an open session) cannot be converted to JSON: turn them into a dictionary first.
Example
Section titled “Example”Create Dictionary → output: resultSet Dictionary Value dict = result key = "processed" value = totalSet Dictionary Value dict = result key = "date" value = today().ToString("yyyy-MM-dd")Write JSON path = "C:/output/summary.json" value = result → output: summaryPathLog message = "Summary saved to " + summaryPathResult in C:/output/summary.json:
{ "processed": 42, "date": "2026-10-15"}Related activities
Section titled “Related activities”- Read JSON — read a JSON file.
- Create Dictionary — build the value to save.