Data to JSON
This function block converts selected input values into a single JSON-formatted string when logging is started. Use the header fields to name each data entry. Only connected data inputs are exported.
π₯ Inputs
Start Logging(input socket) Controls when the block will collect and export data. Provide a boolean signal to start the export process.Data_1...Data_10(input sockets) Generic data inputs that can accept numbers, text, lists or other generic values. Only connected inputs are included in the exported JSON.
π€ Outputs
JSON Data(output socket) A JSON string containing the currently exported key/value pairs. WhenStart Loggingis not active, this output remains empty/None.
πΉοΈ Controls
Data_1 HeaderthroughData_10 HeaderText fields where you can enter user-friendly header names for each corresponding data input.Leave a header field empty to use the default label
Data_Xfor that input.Only connected inputs will be present in the resulting JSON; unused header fields are ignored.
Set Data Headers (UI note)Informational label in the UI reminding you that empty header fields will be ignored.
π― Features
Exports multiple generic inputs into a single JSON object.
Lets you set readable keys using the header controls, or fallback to default
Data_Xkeys.Automatically includes only the inputs that are actually connected at the time of logging.
Produces a single JSON string suitable for saving, sending via REST/MQTT, or logging to files.
βοΈ Running mechanism
The block watches the
Start Logginginput. When this input becomes true it:Reads header texts from the ten header fields.
Collects values from all connected
Data_1β¦Data_10inputs.Matches connected inputs to the corresponding headers (or default
Data_Xlabels).Constructs a JSON object mapping headers to their input values and outputs that object as a JSON string on
JSON Data.
If no logging trigger is given, the block does not produce any JSON output.
If header count and connected data count do not align, the block raises a UI error message β ensure your headers correspond to the data you intend to export.
π Usage instructions
Fill the header fields
Data_1 Headerβ¦Data_10 Headerwith meaningful names for the data you plan to export, or leave them empty to use defaults.Connect the sources you want to export into the corresponding
Data_Xinput sockets.Send a TRUE signal to
Start Loggingto produce the JSON string onJSON Data.Consume the
JSON Dataoutput with export blocks (file writer, REST publisher, MQTT, etc.) or display it in the UI.
π‘ Tips and Tricks
Combine with measurement and detection blocks to create structured logs:
Use outputs from
Object DetectionorObject Detection - Customas inputs to create JSON summaries of detected objects.Feed pose or skeleton coordinates from
Pose EstimationorSkeleton Estimationto export human pose data.Use results from
Find Object,Histogram On Line, orMeasure Position Distancefor analytics and include them in JSON logs.Send OCR outputs from
OCRorOCR (EasyOCR)into this block to export recognized text along with timestamps.
For persistent storage or continuous logging:
Route the
JSON Dataoutput intoCSV Export,Image Logger(for image-related metadata), or a REST/MQTT block (e.g.,REST API - PostorMQTT Publish) to send data to a server or database.
Selectively export only connected values:
You do not need to populate every header. Only connected
Data_Xsockets are included, so you can wire only the signals you need.
π οΈ Troubleshooting
If no JSON appears when you expect it:
Check that
Start Loggingis receiving a TRUE value.Verify that at least one
Data_Xinput is connected.
If field names do not match the exported keys:
Ensure the corresponding
Data_X Headertext field is filled. Empty header fields fall back to defaultData_Xkeys.
If an error indicates mismatched counts:
Confirm the number of connected inputs matches the headers you expect to use, or explicitly name headers only for the inputs you have connected.
To forward JSON to an external system:
Use blocks such as
REST API - Post,MQTT Publish, or database blocks likeSQL-DB Operationsafter this block to deliver or store the JSON payload.
Last updated
Was this helpful?