IMD SolutionComputing LibraryShop main store

Troubleshooting

Why an MQTT tag path bracket shows all array values

Edge computing and IIoT Published 6 min read

Short answer

The MQTT tag holds the whole JSON payload as one string, so a bracketed path suffix cannot select an element. Remove the bracket, add an expression transform that parses the string with jsonGet, and request index 1 for the second element, because JSON array indexes are zero-based.

On this page
  1. Why does a bracket index on the MQTT tag path show every value?
  2. How do I confirm what data type the MQTT Engine tag actually holds?
  3. How do I display one value from a JSON string payload?
  4. Why does the second value need '[1]' instead of '[2]'?
  5. Why did list({value})[1] fail with an unknown-function error?
  6. Is the transport from Node-RED to the broker part of the problem?
  7. Why does the binding show Error_Configuration on the component?
  8. Questions asked

The binding is doing exactly what the tag lets it do: the tag the MQTT subscriber created holds the entire payload as a single JSON string, not a typed array, and a bracket suffix on a tag path can only index a tag the provider exposes as an array. The fix is three moves: remove the bracket from the tag path, delete the Script Transform, and put jsonGet({value}, '[1]') in an Expression Transform. This article walks the fault from the wire to the binding, shows how to confirm the String data type, and works an example that pulls the second element from a payload such as ["Citra","Cascade","Mosaic"].

Why does a bracket index on the MQTT tag path show every value? #

The bracket does nothing here because the tag the MQTT engine creates holds the entire payload as one JSON string, not a typed array: a path suffix such as [2] can index only a tag the provider exposes as an array, and a String tag has no elements.

MQTT transports bytes; it carries no data type. The type comes into existence where the subscriber creates the tag. Brackets have meaning only to the subsystem interpreting them: a suffix on a tag path asks the tag provider for an indexed element, while a bracket string passed to a JSON function operates later, after the binding already holds the complete text. In this fault the path resolved to one scalar string, the suffix had no array to walk, and the binding passed the whole text to the display, brackets and commas included.

How do I confirm what data type the MQTT Engine tag actually holds? #

Open the Tag Browser, enable the data type column, and read it on the exact tag the binding references; in the confirmed fault that column reads String, which means the whole payload arrived as one scalar text value.

The column is hidden by default in some views, so turn it on before drawing any conclusion. Do not infer the type from the formatting of the value: an array-like rendering with brackets and commas is one client's display of text, not proof of an Array tag. Also check the tag the binding actually names. In the diagnostic session, the tag browser showed the content of Hops names while the binding referenced Hops use; similar names on the same topic are easy to confuse, and a good expression tested against a neighbor tag proves nothing. If the column reads String, no path suffix will ever index that tag.

How do I display one value from a JSON string payload? #

Remove the bracket suffix from the tag path, delete the Script Transform, and add an Expression Transform containing jsonGet({value}, '[1]'); the expression parses the JSON text inside the string and hands the binding a single element, with no script return statement needed.

  1. Remove [2] from the end of the tag path so the binding first receives the complete JSON string.
  2. Delete the Script Transform; a direct element lookup does not need it, and it adds a second language context.
  3. Create an Expression Transform and enter exactly jsonGet({value}, '[1]'). {value} is the value the binding passes into the transform, and the second argument is the JSON path.
  4. Confirm the display now shows one value, not the whole payload.

Worked example. The tag holds ["Citra","Cascade","Mosaic"]. Index 0 selects "Citra", index 1 selects "Cascade", index 2 selects "Mosaic". Requesting the second hop with '[1]' returns "Cascade". '[2]' would have returned "Mosaic", the third element, and against a two-element payload it would return nothing usable.

Why does the second value need '[1]' instead of '[2]'? #

JSON array indexes for jsonGet are zero-based: '[0]' selects the first element and '[1]' the second, so the value you would call number 2 is selected with '[1]', and '[2]' returns the third element when the array is long enough.

People count from one; JSON counts from zero. Every index in a JSON path is shifted down by one from the everyday count, which is why the original attempt to grab the third value by appending 2 in brackets both failed to parse and, had parsing worked, would have grabbed the wrong element anyway.

Why did list({value})[1] fail with an unknown-function error? #

list() is a scripting function, not an expression function, so pasting list({value})[1] into an expression throws an unknown-function error, and mixing script syntax into an expression fails for the same reason: the two contexts evaluate different languages.

Think of an expression like a spreadsheet formula: one or more functions over variables that return a single result, with no program structure and no return. A script transform is a program and does need return. Each attempt in this fault maps to one of those two mistakes:

Attempt Why it fails Working form
[2] on the tag path The tag is a String, not an indexed array Bind the full tag and parse it
list({value})[1] in an expression list() is a script function; the expression engine reports an unknown function jsonGet({value}, '[1]')
return in front of the expression Expressions already yield their evaluated result; return belongs to scripts The bare function call
A Script Transform kept alongside the fix Adds a second evaluation context without changing the requirement to parse first One expression, one function

When a script transform genuinely must stay in a design, its null handling is its own trap, and the guide to fixing None versus null in Ignition script transforms covers that separate failure mode.

Is the transport from Node-RED to the broker part of the problem? #

If the full payload still arrives with every element present, the transport is healthy and the fault is representation at the binding, not connectivity; a broken publisher link, broker address, topic or subscription shows up as a missing, stale or disconnected value instead.

Receiving the complete current string is itself the boundary test: it moves the fault from the network to the data type. Work the layer below only if the symptom changes:

  • Publisher link: the publish action completes and traffic reaches the configured broker.
  • Broker endpoint: the publisher and the subscribing engine connection point at the same address and port; read both from their own configuration rather than assuming.
  • Topic: the published topic matches the subscribed topic, character for character.
  • Update timing: the tag changes shortly after each publication; if not, check subscription state before touching any transform.
  • Payload completeness: every expected element is present in the received value.

If the payload itself is malformed, no expression will save it. Stray or truncated characters are a serialization fault, covered step by step in the article on extra characters in a PLC MQTT JSON payload. A related conversion trap sits on the value side: numbers that arrive wrapped in quotes fail analog points, which the article on a quoted MQTT JSON value failing an analog point walks through.

Why does the binding show Error_Configuration on the component? #

Hover over the Error_Configuration badge on the component to read the actual fault, and check that the binding names the same tag you diagnosed, because a correct expression evaluated against a neighbor tag with a similar name proves nothing.

The badge is a summary, not a diagnosis; the tooltip text names the specific problem, such as a function that does not exist in the expression context or a tag that cannot be resolved. After applying the expression fix, read the display against the worked example: one element, the one the index selects, and no brackets left anywhere in the rendered value. If the whole payload still appears, the bracket is still on the tag path or the transform is still a script; if the element is off by one, the index still carries the everyday count instead of the zero-based one.

Questions asked

Can a bracketed tag path ever index a payload directly?

Yes, but only when the receiving tag provider exposes the tag with a true Array data type, which tag configuration can set for tags the platform manages directly. Path indexing then selects elements without any parsing. It fails on an MQTT-delivered payload because that payload arrives as one String value containing JSON text, and a string has no addressable elements for a path suffix to walk.

Does it matter how the publisher formatted the payload?

Only indirectly. MQTT moves bytes and carries no data type, so whatever structure the publisher built is gone by the time the subscriber decides what the tag should hold. The deciding fact is the data type column on the receiving tag, not the shape the publisher displayed. A second subscriber that renders the same topic as an array is showing its own interpretation of the text, not proof of an array tag.

How do I show two elements from the same payload?

Bind the same string tag to two components and give each its own expression transform, changing only the bracketed index in the JSON path, for example 0 on one and 1 on the other. Each expression re-parses the string and returns one element. For many elements or conditional logic, a script transform that parses the payload once and returns a structure becomes the cleaner option.

Is a script transform ever better than the expression here?

Yes, when the extraction needs loops, error handling or decisions a single expression cannot express. For a plain element lookup it adds a second language context for no benefit, and mixing the two, a return statement inside an expression or list-style script functions in an expression, is exactly what produced the unknown-function error seen in this fault.

Keep reading

  • Troubleshooting

    Why a quoted MQTT JSON value fails an analog point

    MQTT forwards your payload bytes unchanged, so a quoted "868.9640" is a JSON string and an analog point rejects it. Either publish a real JSON number at the source, or convert the text in a receiver that parses it, as Geo SCADA 2023's Text JSON driver did in the reported case. Confirm with one controlled test that changes only the quotation marks.

    Edge computing and IIoT

  • Explainer

    Shrinking a Sparkplug JSON payload on a narrow link

    Casting the JSON to bytes changes the Sparkplug datatype tag, not the size: String and Bytes metrics both ride one protobuf length-delimited field with the same length prefix. The example's ~700-byte object minifies to ~400 bytes and shrinks further as typed metrics with aliases; with a 1460-byte IPv4 segment limit, the gain is bytes on the link, not packets.

    Edge computing and IIoT

  • Troubleshooting

    Why MQTT Engine shows online status after an edge node drops

    An Info/Online tag that stays true with Good quality is not proof the edge node is alive: Engine's online state comes from the node's Sparkplug death certificate, and earlier Engine versions marked tags stale only on Engine shutdown. Read Info/Online, tag quality and Store & Forward stored metrics as three separate indicators, retest on Engine 4.0.8 with Ignition 8.0.16 or later, and compare against a node that reports correctly before escalating.

    Edge computing and IIoT

Vijeo Historian log all samples for unchanged tag values