ByteChef LogoByteChef

JSON File

Reads and writes data from a JSON file.

Categories: Helpers

Type: jsonFile/v1


Actions

Read from File

Name: read

Reads data from a JSON file.

Properties

NameLabelTypeDescriptionRequired
fileTypeFile TypeSTRING
Options JSON, JSONL
The file type to choose.true
fileEntryFile EntryFILE_ENTRYThe object property which contains a reference to the JSON file to read from.true
isArrayIs ArrayBOOLEAN
Options true, false
The object input is array?false
pathPathSTRINGThe path where the array is e.g 'data'. Leave blank to use the top level object.false
pageSizePage SizeINTEGERThe amount of child elements to return in a page.false
pageNumberPage NumberINTEGERThe page number to get.false

Example JSON Structure

{
  "label" : "Read from File",
  "name" : "read",
  "parameters" : {
    "fileType" : "",
    "fileEntry" : {
      "extension" : "",
      "mimeType" : "",
      "name" : "",
      "url" : ""
    },
    "isArray" : false,
    "path" : "",
    "pageSize" : 1,
    "pageNumber" : 1
  },
  "type" : "jsonFile/v1/read"
}

Output

The output for this action is dynamic and may vary depending on the input parameters. To determine the exact structure of the output, you need to execute the action.

Write to File

Name: write

Writes workflow data to a JSON or JSONL file. Source Data is the object or array to serialize (typically a data pill), not a file path.

Properties

NameLabelTypeDescriptionRequired
fileTypeFile TypeSTRING
Options JSON, JSONL
The file type to choose.true
typeTypeSTRING
Options OBJECT, ARRAY
Whether Source Data is a JSON object or a JSON array.false
sourceSource DataOBJECT
Properties {}
The JSON object to write. Map this from a previous step with a data pill. This is the data itself, not a file path.true
sourceSource DataARRAY
Items []
The JSON array (list of objects) to write. Map this from a previous step with a data pill. For JSON, the file contains one JSON array. For JSONL, each item is written as one JSON object per line.true
filenameFilenameSTRINGFilename to set for binary data. By default, "file.json" will be used.true

Example JSON Structure

{
  "label" : "Write to File",
  "name" : "write",
  "parameters" : {
    "fileType" : "",
    "type" : "",
    "source" : [ ],
    "filename" : ""
  },
  "type" : "jsonFile/v1/write"
}

Output

Type: FILE_ENTRY

Properties

NameTypeDescription
extensionSTRING
mimeTypeSTRING
nameSTRING
urlSTRING

Output Example

{
  "extension" : "",
  "mimeType" : "",
  "name" : "",
  "url" : ""
}

Additional Instructions

Write to File

source is the JSON to serialize into the file, not a file path and not source code. Map it from a previous step with a data pill.

  • Type OBJECT: writes one JSON object.
  • Type ARRAY: writes a JSON array of objects. For JSONL, each array item is written as one JSON object per line.

The action returns a FILE_ENTRY for the created file.

How is this guide?

Last updated on

On this page