Widgets/Transformer
Text to Object Widget
Text to Object Widget
A "Transformer" type widget. Text to Object Widget converts JSON-formatted text into JavaScript objects. This widget is crucial when you need to work with JSON data or convert text-based configurations into usable objects in your workflow.
Â
Inputs
- string (DataType: String) The JSON-formatted text string to be parsed. This should be valid JSON syntax.
Outputs
-
object (DataType: JsonObj) The resulting JavaScript object after parsing the input text.
-
error (DataType: Boolean) Indicates whether JSON parsing failed.
truewhen parsing fails.
Â
📌 Important Notes
- The input text must be valid JSON format
- Common JSON parsing errors include:
- Missing or extra commas
- Unmatched brackets or braces
- Invalid property names (must be in double quotes)
- Invalid values
Â
Examples
Basic JSON Parsing
This example shows how to parse a simple JSON string into an object:
Drag the example onto the workspace to explore and experiment!
In this example
- The Button widget triggers the flow
- The Text widget provides a JSON-formatted string
- The Text to Object widget converts the string into a JavaScript object
- The result can be viewed in the Port Inspector by clicking the output port of the Text to Object widget
Note: In the drag-and-drop exercise, the flow includes an Object to Text widget connected to a Text widget to display the result directly. Both methods show the same output.
Â
Error Handling
This example demonstrates how the widget handles invalid JSON:
Drag the example onto the workspace to explore and experiment!
In this example
- The Text widget provides invalid JSON text to the Text to Object widget through the
stringport - The Text to Object widget fails to parse due to invalid syntax and transmits
truethrough theerrorport - The Display widget shows the error state
Â
📌 Additional Notes
- The widget supports all JSON data types:
- Objects
- Arrays
- Strings
- Numbers
- Booleans
- null
Â
Glossary
-
JSON format
A standardized text representation for structured data using JavaScript Object Notation (JSON): objects with double-quoted keys, arrays in square brackets, and values such as strings, numbers, booleans, null, objects, or arrays.
-
Port Inspector
The Port Inspector is a panel in Kemu’s Logic Mapper that shows details about a selected port.
It can be enabled or disabled from the settings menu (gear icon).
When visible, clicking a port will load its information, including:- Data Type (e.g., Object, Array)
- Port Type (Source or Target)
- Last Value (latest transmitted data)
This helps you inspect values, review port behavior, and debug connections.