Skip to main content

Datasources and JSON filters

A datasource supplies structured data to an element. Create it with Add datasource and open the resulting .datasource file in the Forms Editor.

For an end-to-end pattern using HTTP data, formatted labels, weather icons, and explicitly labeled simulated conditions, see Weather dashboard. The same separation between source data and presentation also applies to room cards and source-selection lists.

Configure a datasource in VS Code​

A .datasource file stores the source configuration; a .json file contains local sample data. Attaching the datasource to an element tells that element what to consume. Its attachment can also contain a sequence of filters.

  1. Run Add datasource in the AVstudio project and give it a meaningful name.
  2. Open the resulting .datasource file. Check that the editor selector shows AVS Forms Editor.
  3. For a local example, keep No remote selected.
  4. Under Datasource local data, select an existing JSON file or click Create new to create one. Open file opens the selected data file for editing.
  5. Leave Datasource format function empty until a transformation is needed.
  6. Save the datasource and JSON documents before testing the consuming page.

Local datasource configuration in the VS Code Forms Editor with catalog-rooms.json selected

The screenshots use NG 0.1.54. The form in the main editor configures the open datasource file. The Element Properties sidebar can retain the previously selected control; it is not the datasource's configuration panel.

Form controlPurpose
No remoteUse local data. The message “Only local data is supported” describes this selected tab, not the entire extension.
Web (HTTP)Select a Web connector, URL postfix, and optional polling interval.
WebsocketSelect a WebSocket connector and root-relative incoming JSON message path; updates are pushed rather than polled.
MQTTSelect an MQTT connector and Topic.
Datasource format functionSelect a formatter, or use Create new to start one. Leave it unset when the incoming shape is already suitable.
Datasource local dataChoose the local JSON fixture. Use Open file to edit its records.

Test an HTTP request and save local data​

In 27.0.29, the canvas uses Local Data for its static preview. Remote connectors activate in Live Preview and production. The datasource form's data-flow timeline explains the fetch, polling/extraction, formatter, storage, and output stages; a static preview is not evidence that a remote request ran.

  1. Open the datasource, select Web (HTTP), and configure the connector, URL postfix, and polling where required.
  2. Use Test request and inspect the response preview before choosing field paths or filters.
  3. Select or create a local JSON file for Datasource local data. Use the form's save/fill-local-data workflow to retain a fixture for the canvas.
  4. If a formatter is selected, read the confirmation before filling Local Data: the saved result is formatted data, rather than the raw response. Check the resulting JSON shape.
  5. Reopen the consuming page and inspect its static data, then run Live Preview to test actual remote updates.

You can create a formatter directly in the datasource folder; the form selects its relative ./name.js reference. Very large test responses are capped with a truncation notice; this preview limit does not establish the complete response size or contents.

Failed tests open Output → AVStudio Datasource, which reports certificate, DNS, and connection causes. The editor's request tester supports self-signed/expired certificates; this does not change browser or deployed-runtime TLS trust. A passing editor test must still be followed by a runtime request test. Edit datasource filters starts with its JSON tree collapsed at the top level and keeps long output within its panel.

Receive WebSocket data​

Choose Websocket, select the connector, and set the message path. Store remoteFetchType: "websocket", wsConnectorUid: "connectors/panel.websocket", and wsMessagePath: "payload.rooms" to consume a rooms array from incoming JSON. The path is relative to the message root; omit the displayed root. prefix from the saved path. Empty selects the whole message, and a missing path leaves the consumer unchanged. A formatter can transform the extracted result before element filters run. See WebSocket receive and send.

Start with local data​

Use Add local data JSON from the datasource folder. For a room list, use datasources/rooms.json with these records:

IDNameOnline
1Conference Roomtrue
2Training Roomfalse

Set localJson in rooms.datasource to ./rooms.json. Local data paths are relative to the datasource's folder. Local fixtures let you test layouts without depending on a live service.

Attach and display​

  1. Open the consuming .page in the visual editor.
  2. Select the control and locate Element Properties → Attached datasource. In 27.0.0 and later this is an always-visible inline card; filter controls appear only after attachment.
  3. Choose the datasource from the dropdown. The example uses datasources/catalog-rooms.datasource on the Rooms Subpage List.
  4. With no filter steps, the sidebar displays Untouched datasource data used.
  5. Configure the control's content or input parameters to read fields from that result.

Subpage List with Attached datasource expanded in VS Code and four sample room cards on the canvas

Attaching data does not automatically choose a displayed field or send commands to devices. A Text element needs a text binding; a Subpage List needs its target page and per-item parameter mapping.

On the consuming element, select the datasource. The datasource reference includes the project-root folder and extension.

Select datasources/rooms.datasource as the element’s attached datasource. In the text dynamic-value picker, choose the first record’s name field (#datasources/rooms.datasource:0.name#).

This binding displays the first room name. To repeat an interface for every room, use a Subpage List and item-relative parameter tokens.

Filter the result​

Filters belong to the consuming element's Attached datasource configuration. Two elements can use the same datasource with different filter steps; changing one attachment's filters does not rewrite the source JSON file.

Open the JSON filter editor​

  1. Select the consuming element and expand Attached datasource.
  2. Click Edit datasource filters.
  3. Check the breadcrumb at the top: it identifies the page, container, element, and datasource being edited.
  4. Inspect the JSON preview before adding a step. The sample source contains four objects with a name field.
  5. Right-click a node in the JSON preview to see the operations available for that node.

Example: keep only Boardroom​

In the sample, right-click the name: Boardroom field. The menu offers Pick parent object (root) → 0 and Filter array by (root) → name (root). These have different results.

  1. Choose Filter array by for the name field.
  2. In Add filter, confirm the Key points to name.
  3. Choose equals in Operator and enter Boardroom in Value.
  4. Click Add.

Add filter dialog in VS Code with name equals Boardroom

The result is an array containing one room. The preview shows 1 item, and Datasource modifications steps lists filter (root) → name = Boardroom.

JSON filter result showing a one-item Boardroom array and its filter step in VS Code

Return to the host page to inspect the list, then save the page document. The change is stored on the element attachment. The screenshot demonstrates a temporary filter; the documentation sample was restored to its four-room list afterward.

Pick versus filter​

OperationResultWhen to use it
PickSelects a subtree, such as one object or a nested array.A response wraps the useful data inside a property, or you need one particular object.
FilterKeeps array items that meet a condition. The result remains an array.Show only matching rooms, devices, or records.

For a response shaped like { "rooms": [...] }, first select the rooms array, then filter its records. Steps are applied in sequence, so later paths must make sense in the output of the earlier steps.

Selecting Pick parent object on the Boardroom field produces the first object rather than a one-item array. That is unsuitable as a Subpage List replication source. Use Filter array by when you want one matching card while preserving the list shape.

Operators include equality, containment, existence, empty/null checks, and boolean checks, with inverse options where supported. Match the operator to the actual field type: boolean true, string "true", and a missing field are different data.

Review or remove steps​

Use the Preview steps checkboxes to inspect the effect of steps. To remove a filter from the configuration, use its delete button, then check the preview and sidebar summary again. Removing the only step restores the untouched source result. Save the host page after editing the chain.

Always test no matches, one match, and multiple matches. A valid empty array means there are no rows to render; it does not by itself indicate a connection failure.

Fetch remote data​

The inspected Forms Editor exposes Web (HTTP), Websocket, and MQTT source tabs. Create the corresponding connector before selecting it in the datasource.

SourceFields to configure
Web (HTTP)Web Connector, URL postfix, and Polling interval. The postfix identifies the endpoint relative to the connector configuration.
WebsocketWebsocket Connector. Confirm that its incoming data has the structure expected by the consumer.
MQTTMQTT Connector and Topic. Confirm the publisher's actual message shape and types.

For HTTP, an empty Polling interval shows No polling. A configured interval forces a refetch every N milliseconds, including after errors. For example, 5000 means five seconds. Choose an interval the service can support; faster polling is not a remedy for an incorrect endpoint or response format.

Select the remote fetch type and matching connector. Connector references use paths such as connectors/api.web. Depending on the source, configure a URL postfix or MQTT topic. pollingInterval is in milliseconds; choose it to suit the device or service.

Test the connection first, then confirm the actual response shape before configuring element field paths. Local data is useful during design but does not prove remote authentication or connectivity works.

Format incoming data​

A datasource can reference a sibling formatter such as ./formatter.js. Use a synchronous, dependency-free function to transform the response. For a list receiving one object:

function formatData(data) {
if (data == null) return [];
return Array.isArray(data) ? data : [data];
}

Select the formatter in the datasource configuration. Verify its output with normal, empty, and unexpected input from your source.

Keep the formatter synchronous and dependency-free. The example above only normalizes the outer shape; if the server returns { "rooms": [...] }, select or return that nested array explicitly. Returning [null] or wrapping an error object as a row can create an apparently valid but unusable list.

Map records into a Subpage List​

The sample catalog-rooms.json contains four room records:

Name
Boardroom
Meeting room
Training room
Lobby

The list attaches catalog-rooms.datasource, targets the reusable room-card page, and maps its roomName input to each record's name field. The sidebar shows a datasource binding with *.name. In token form, the item-relative reference is #datasources/catalog-rooms.datasource:*.name#.

A fixed path such as 0.name addresses the first record; *.name supplies the current item when mapping repeated cards. See Subpage List for target-page setup, parameter mapping, and grid layout.

Verify and troubleshoot​

Since 27.0.35, Health Check includes a list-datasource-shape rule for Subpage Lists. For a statically resolvable local datasource, it checks the result after the element's filter/pick steps. A non-array result or missing local source produces a warning; empty or malformed local JSON produces an error. For { "rooms": [...] }, pick rooms to retain an array rather than picking one room object.

The 27.0.41 implementation skips this rule for dynamic datasource keys/filter steps, configured remote sources, and datasources with formatters. A clean check therefore does not establish their runtime result shape. Inspect the actual result in Edit datasource filters and Live Preview.

  1. Save the source configuration and any local JSON or formatter changes.
  2. Open Edit datasource filters from the intended consuming element.
  3. Check the source values, selected subtree, step sequence, and final data shape.
  4. Return to the visual canvas and verify the displayed values or number of repeated cards.
  5. Run Run Project Health Check, then test in Live Preview. Verify remote connectivity separately when using a live source.
SymptomWhat to check
Local file is unavailableConfirm the file is valid JSON and localJson points to the correct file relative to the datasource folder.
Field is blankCheck spelling, letter case, record shape, binding path, and whether filtering removed the record.
Only one card appearsCheck for an intentional filter, a one-record source, or a fixed first-item binding.
No list instances appearVerify the final result is an array. A picked object is not a list source; an empty array legitimately renders no rows.
Every card shows the same nameCheck the per-item mapping uses the current record rather than 0.name.
Filter behaves unexpectedlyCompare field types and review each step's output. Paths can change after a Pick step.
Local sample works but remote data does notCheck the connector, endpoint/topic, authentication, and actual response shape.
Formatter produces an errorInspect its selected reference and test normal, null, empty, and unexpected inputs.
Data is correct but no device command is sentConfigure Actions; a datasource supplies incoming data.