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. When Start Logging is not active, this output remains empty/None.

πŸ•ΉοΈ Controls

  • Data_1 Header through Data_10 Header Text 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_X for 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_X keys.

  • 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 Logging input. When this input becomes true it:

    • Reads header texts from the ten header fields.

    • Collects values from all connected Data_1 … Data_10 inputs.

    • Matches connected inputs to the corresponding headers (or default Data_X labels).

    • 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

  1. Fill the header fields Data_1 Header … Data_10 Header with meaningful names for the data you plan to export, or leave them empty to use defaults.

  2. Connect the sources you want to export into the corresponding Data_X input sockets.

  3. Send a TRUE signal to Start Logging to produce the JSON string on JSON Data.

  4. Consume the JSON Data output 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 Detection or Object Detection - Custom as inputs to create JSON summaries of detected objects.

    • Feed pose or skeleton coordinates from Pose Estimation or Skeleton Estimation to export human pose data.

    • Use results from Find Object, Histogram On Line, or Measure Position Distance for analytics and include them in JSON logs.

    • Send OCR outputs from OCR or OCR (EasyOCR) into this block to export recognized text along with timestamps.

  • For persistent storage or continuous logging:

    • Route the JSON Data output into CSV Export, Image Logger (for image-related metadata), or a REST/MQTT block (e.g., REST API - Post or MQTT 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_X sockets are included, so you can wire only the signals you need.

πŸ› οΈ Troubleshooting

  • If no JSON appears when you expect it:

    • Check that Start Logging is receiving a TRUE value.

    • Verify that at least one Data_X input is connected.

  • If field names do not match the exported keys:

    • Ensure the corresponding Data_X Header text field is filled. Empty header fields fall back to default Data_X keys.

  • 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 like SQL-DB Operations after this block to deliver or store the JSON payload.

Last updated

Was this helpful?