Skip to content

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.

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 writes null.
  • 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.
ParameterTypeDefaultDescription
pathstring—Path of the output JSON file, including its folder.
valueobject—The value to convert: dictionary, list, DataTable, text, number…
ParameterTypeDefaultDescription
indentedbooltrueFormat with line breaks and indentation so it is easy to read. With false, everything goes on one line (smaller file).

Returns a string with the path of the written file (as you gave it in path).

MessageCause 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.

Create Dictionary → output: result
Set Dictionary Value dict = result key = "processed" value = total
Set Dictionary Value dict = result key = "date" value = today().ToString("yyyy-MM-dd")
Write JSON path = "C:/output/summary.json" value = result → output: summaryPath
Log message = "Summary saved to " + summaryPath

Result in C:/output/summary.json:

{
"processed": 42,
"date": "2026-10-15"
}