JSON Conversion

JSON Conversion

JSON Conversion states convert data from various file formats into JSON for further processing within the circuit.

Available States:

  • JSON to JSON

  • CSV to JSON

  • XML to JSON

  • YAML to JSON

  • XLSX to JSON

  • TXT to JSON

Configuration and Common Fields  

The following configuration settings and payload fields are common across all JSON Conversion states. In addition to these, each state may include specific fields described in its respective section.
  1. Go to the right pane of your circuit.

  2. Select Data Transformation and choose JSON Conversion.

  3. Select the required state in the JSON conversion category.

  4. Drag and drop the selected state into your circuit.

  5. Under Configuration:

    • Type is set to Task by default.

    • Task ID is preselected based on the chosen state and can be modified from the dropdown.

  1. Configure the Payload using the following common fields (as applicable):

    • Qntrl File ID – The ID of the file uploaded in the Qntrl Files module.

    • Index – The starting index of the data to process.

    • Range – The number of records to process from the starting index.

    • Encoding Type – The file encoding format. Defaults to UTF-8 if not specified. Incorrect encoding may prevent the file from being read.

  1. Configure Error Handling, if required.

  2. To configure Input Path, Output Path, Result Path, and Result Selector, click Input/Output next to the Configuration tab. For more details, refer to Input & Output Processing.

JSON to JSON

Transforms JSON data into another JSON structure. Instead of using a Function state, this state allows inline JSON transformation using scripting.
Supported Script Types  :
  • JSONata: A powerful JSON querying and transformation language with built-in functions for filtering, aggregation, and computation. Ideal for advanced querying, concise expressions, and complex or ad-hoc data manipulation.
  • JSLT: A structured JSON transformation language designed for clear input-to-output mapping and format conversion. Best suited for template-driven transformations and controlled structural changes.
Builder View Additional Properties
  • Data: Static or dynamic input JSON.

  • Qntrl File ID: Provide a file-based JSON input instead of inline data (optional).

  • Script Type: Select JSONata or JSLT from the dropdown.

  • Script: Script the transformation logic

  • Variables: Define variables to reference within the script

Code View
JSONata
{
  "Json 2 Json Converter": {
      "start": true,
      "module": "json_conversion",
      "task_id": "json_to_json",
      "payload": {
  "qntrl_file_id": "{file_id}",
  "script_type": "JSONata",
  "script": "Account.Order.Product"
      },
    "next": "End"
 }
}

 

JSLT

{
  "Json 2 Json Converter": {
     "start": true,
     "module": "json_conversion",
     "task_id": "json_to_json",
     "payload": {
"qntrl_file_id": "{file_id}",
"script_type": "Jslt",
"script": {
    "user": {
"name": "upper-case(.name)",
"age": ".age",
"location": ".city",
"isAdult": ".age >= 18"
}
  }
},
     "next": "End"
   }
}

 

JSONata with Variables

{
  "Json 2 Json Converter": {
      "start":true,
      "module": "json_conversion",
      "task_id": "json_to_json",
      "payload": {
"variables": {
     "greeting": "Hello"
},
"data": {
    "name": "Alice"
},
"script_type": "JSONata",
  "script": "$greeting & ', ' & name"
}
       "next": "End"
    },
} 

  

CSV to JSON    

Converts a CSV file into JSON. Supports custom delimiters, headers, quote characters, and null value handling.

Builder View Additional Properties
  • Has Header: Enable if the first row contains column headers. When enabled, the first row is used as column names. When disabled, columns are auto-named as column1, column2, etc.
  • Header: Manually define column names when Has Header is disabled.

  • Delimiter: Character used to separate values (e.g., comma, semicolon)

  • Quote Char: Character used to quote fields containing special characters, preventing them from being split.

  • Escape Char: Character used to escape the quote character within a field.

  • NA Values: Strings to treat as missing values (NaN).

  • Null Substitute: Replacement value for recognized NaN entries.

 

When defining headers manually (i.e., Has Header is disabled), each column entry supports the following keys:

  • name: The column name to assign in the JSON output.

  • type: The data type of the column (e.g., string, number, datetime).

  • input: Specify the format and timezone of the date value in the source CSV.

  • output: Specify the desired format and locale of the date value in the JSON output.

Code View
{
  "New State 1": {
     "type": "task",
     "module": "json_conversion",
     "task_id": "csv_to_json",
     "payload": {
"qntrl_file_id": "{file_id}",
"has_header": false,
"delimiter": ",",
"quote_char": "\"",
"headers": [
{
    "name": "EmployeeID",
    "type": "number"
},
{
    "name": "DOB",
    "type": "datetime",
    "input": {
    "format": "yyyy-MM-dd HH:mm:ss",
    "zone": "UTC"
},
"output": {
    "format": "yyyy-MMMM-dd HH:mm:ss",
    "locale": "fr"
}
      }
     ]
    },
   "end": true
 }
}

 

XML to JSON 

Converts an XML file into its equivalent JSON representation. Only the common payload fields apply — no additional configuration is required.
Code View
{
    "XML Json Converter": {
"start":true,
"module": "json_conversion",
"task_id": "xml_to_json",
"payload": {
"qntrl_file_id": {file_id},
"range":5
},
        "next": "End"
    },
}

 

YAML to JSON  

Converts a YAML file into JSON format. Supports alias limiting to handle complex YAML structures safely.

Builder View Additional Properties
  • Max Aliases: Specify the maximum number of YAML aliases (references) allowed. YAML supports anchors (&) and aliases to reference repeated values.
 
Code View
{
"YAML Json Converter": {
"start": true,
"module": "json_conversion",
"task_id": "yaml_to_json",
"payload": {
"qntrl_file_id": "{file_id}",
"max_aliases": 10
},
"next": "End"
}
}

 

XLSX to JSON  

Converts spreadsheet data from an Excel file into JSON. Supports sheet selection and flexible header configuration.

Builder View Additional Properties
  • Sheet Index: Index of the sheet to process.

  • Sheet Name: Name of the sheet to process.

  • Has Header: Indicates whether the first row contains column headers.

  • Header Index: Row index to use as the header row   

Header Behavior:  

    • If has_header = true, the first row is treated as column names.

    • If has_header = false, columns are auto-generated as column1, column2, etc.

    • You can manually define column names when headers are not present.

Code View

{
"XLSX Json Converter": {
"start": true,
"module": "json_conversion",
"task_id": "xlsx_to_json",
"payload": {
"qntrl_file_id": "{file_id}",
"has_header": true,
"headers": [
{
"name": "person",
"type": "string"
},
{
"name": "age",
"type": "number"
},
{
"name": "DOB",
"type": "datetime",
"input": {
"format": "yyyy-MM-dd HH:mm:ss",
"zone": "UTC"
},
"output": {
"format": "yyyy-MMMM-dd HH:mm:ss",
"locale": "fr"
}
}
]
},
"next": "End"
}
}

TXT to JSON  

Converts structured text files into JSON. Supports three parsing methods depending on the structure of your text file.

Builder View Additional Properties

  • Delimiter: Character used to split values in delimiter-based parsing (e.g., ,, |, >).

  • Has Header: Enable this option if the first row contains column headers. When enabled, the first row is treated as column names.

  • Columns: If Has Header is disabled, define columns manually by specifying the column name, data type, and parsing rule.

  • Parsing Methods  

  • Delimiter-Based Parsing: Used when values in the text file are separated by a consistent character such as ,, |, or >.

  • Index-Based (Fixed-Width) Parsing: Used for fixed-length text files where each field occupies a defined character position. Specify the start and end positions to define column boundaries.

  • Regex-Based Parsing: Used for unstructured or semi-structured text files (e.g., log files) where fields are identified using pattern matching.


Notes
Delimiter-based parsing and fixed-width parsing cannot be used simultaneously.

 

Code View

i) Index Based Transformation

-> Input  

John                Doe                 35  
Jane                Smith               28  
Bob                 Johnson           42  

-> Config

{
"TXT Json Converter": {
"start": true,
"module": "json_conversion",
"task_id": "txt_to_json",
"payload": {
"qntrl_file_id": "{file_id}",
"has_header": false,
"columns": [
{
"name": "firstName",
"start": 0,
"end": 19,
"type": "string"
},
{
"name": "lastName",
"start": 20,
"end": 39,
"type": "string"
},
{
"name": "age",
"start": 40,
"end": 42,
"type": "number"
}
]
}
}
}

 

-> Response

[
  { "firstName": "John", "lastName": "Doe", "age": 35 },
  { "firstName": "Jane", "lastName": "Smith", "age": 28 },
  { "firstName": "Bob", "lastName": "Johnson", "age": 42 }
]

 

ii) Regex Based Transformation

-> Input  

2025-07-29 10:00:00 INFO User logged in
2025-07-29 10:05:00 ERROR Failed to load resource
2025-07-29 10:10:00 INFO User logged out

-> Config

 {
"TXT Json Converter": {
"start": true,
"module": "json_conversion",
"task_id": "txt_to_json",
"payload": {
"qntrl_file_id": "{file_id}",
"has_header": false,
"columns": [
{
"name": "date",
"regex": "^\\d{4}-\\d{2}-\\d{2}",
"type": "date"
},
{
"name": "time",
"regex": "\\d{2}:\\d{2}:\\d{2}",
"type": "time",
"format": "HH:mm:ss"
},
{
"name": "level",
"regex": "(INFO|ERROR|WARN)",
"type": "string"
},
{
"name": "message",
"regex": "(INFO|ERROR|WARN) (.*)$",
"type": "string"
}
]
}
}
}

 

-> Response

[
  {
     "date": "2025-07-29",
     "time": "10:00:00",
     "level": "INFO",
     "message": "User logged in"
  },
  {
     "date": "2025-07-29",
     "time": "10:05:00",
     "level": "ERROR",
     "message": "Failed to load resource"
  },
  {
     "date": "2025-07-29",
     "time": "10:10:00",
     "level": "INFO",
     "message": "User logged out"
  }
]

 

iii) Delimiter Based Transformation  

-> Input  

John | Doe | true | 1985-12-15
Jane | Smith | false | 1990-05-10
Bob | Johnson | true | 1978-03-22

-> Config

{
"TXT Json Converter": {
"start": true,
"module": "json_conversion",
"task_id": "txt_to_json",
"payload": {
"qntrl_file_id": "{file_id}",
"has_header": false,
"delimiter": "|",
"columns": [
{
"name": "firstName",
"type": "string"
},
{
"name": "lastName",
"type": "string"
},
{
"name": "isActive",
"type": "boolean"
},
{
"name": "birthDate",
"type": "date"
}
]
}
}
}

-> Response

[
{
    "firstName": "John",
    "lastName": "Doe",
    "isActive": true,
    "birthDate": "1985-12-15"
},
{
    "firstName": "Jane",
    "lastName": "Smith",
    "isActive": false,
    "birthDate": "1990-05-10"
},
{
    "firstName": "Bob",
    "lastName": "Johnson",
    "isActive": true,
    "birthDate": "1978-03-22"
}
]


    • Related Articles

    • JSONto JSON

      Transforms JSON data into another JSON structure. Instead of using a Function state, this state allows inline JSON transformation using scripting. Supported Script Types : JSONata: A powerful JSON querying and transformation language with built-in ...
    • JSON Path

      Path serves to locate specific parts or components within a JSON object. These paths start with the '$' symbol and follow JSONPath syntax. It is used to access particular elements or values within JSON objects passed in the Input Path, Output Path, ...
    • Introduction to States of Circuit

      States are the building blocks of a circuit that can perform tasks, make decisions, or simply pass the output from one state to another. The state defines a specific task or process that has to be executed in that segment of the circuit. Circuit ...
    • Overview

      Any system is defined by the data it receives as input, the way it processes that data, and the output it generates. In a Circuit execution, the input to the circuit is provided as JSON key-value pairs. This JSON is passed as input to the initial ...
    • Output Path

      Output Path enables you to select a portion of the state's output and transfer it to the next state for processing, eliminating any unecessary objects from the JSON output. If the Output Path isn't specified, the entire JSON node (determined by the ...

    You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.