IMD SolutionComputing LibraryShop main store

Troubleshooting

Why a quoted MQTT JSON value fails an analog point

Edge computing and IIoT Published 6 min read

Short answer

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.

On this page
  1. Why does a quoted JSON value fail an analog point while an unquoted one works?
  2. Where along the MQTT path does the message stop being usable?
  3. Can the analog point be forced to accept the string?
  4. Should you fix the publisher or the receiver?
  5. How do you run the quotation-mark test?
  6. How do you prove the value is freshly acquired?
  7. Questions asked

Your analog point is not broken and the broker is not corrupting anything. The measurement arrives as a JSON string because the publisher quoted it, and an analog point needs a JSON number. Two fixes work: publish an unquoted number at the source, or convert the string in a receiving driver that parses text, which is what the Text JSON driver in Geo SCADA 2023 did in the reported installation. Below is how to tell a delivery fault from a type fault, how to run the one test that proves it, and how to prove the value you see is fresh.

Why does a quoted JSON value fail an analog point while an unquoted one works? #

MQTT carries the payload as opaque bytes, so the broker forwards "value": "868.9640" exactly as published; the parser sees a JSON string token, and an analog point that needs a numeric token rejects it. Mosquitto does not inspect or rewrite JSON during forwarding, and no MQTT version changes that, because the payload is application data end to end. The JSON specification distinguishes a string (in quotation marks) from a number (no quotation marks), and a receiving parser honors that distinction even when both render as the same characters on screen.

The reported payload looked like this:

{
  "main": {
    "value": "868.9640",
    "raw": "00868.9640",
    "pre": "868.9640",
    "error": "no error",
    "rate": "0.000060",
    "timestamp": "2024-12-18T18:27:05+0100"
  }
}

Selecting the correct member under main is one operation; converting its type is a second one. A parser can locate the string successfully, and the analog-point assignment still fails at the second step. Changing only that member to "value": 868.9640 in a test client populated the same analog point immediately, which pins the cause on the JSON type and nothing else.

Where along the MQTT path does the message stop being usable? #

A message with the wrong JSON type still reaches the application, so before touching the parser you separate connection faults, which stop delivery, from conversion faults, which deliver an unusable value. Work upward from the physical link and stop at the first layer that fails:

  • Link and listener. Confirm the publisher, broker host and SCADA host each have an active interface and that the broker address and listener port in both clients match the running broker. A fault here means the payload never arrives at all.
  • Connection state. Check that the publisher and the SCADA subscription both show as connected at the broker, and that the subscription topic matches the topic the measurement is published to. A routing mismatch delivers the wrong message, not a mistyped one.
  • Captured payload. Subscribe to the topic with a separate MQTT client and inspect the received bytes. Do not trust a display that renders strings and numbers alike; the same extra characters in a PLC MQTT JSON payload that break a parse are only visible in the raw capture.
  • Point diagnostics. Read the analog point's quality and last-update time. A delivered message with a bad type leaves the point at its previous state, not at zero.

If the capture shows the payload arriving intact and the point still does not update, you have a conversion fault, and no amount of port or network reconfiguration will change the type of a delivered JSON token.

Can the analog point be forced to accept the string? #

In the reported installation, identified as Geo SCADA 2022 with build 23 update 85.8650, no analog-point setting forced that coercion, and there was no string point available for the value; what resolved it was the Text JSON driver introduced with Geo SCADA 2023, which parses string members and converts them to numbers. Treat that build as the identification of one installation, not as a compatibility rule for every release, and confirm driver availability against the manufacturer documentation for your installed and target versions before you plan the change.

If you take the upgrade route:

  • Back up the current configuration and record the broker connection, subscription, field selection and analog-point settings as they stand.
  • Test the Text JSON driver on a standby server or outside the live acquisition path first, using the real payload above.
  • Select the nested member under main and distinguish it from raw, pre and rate, which are not the measurement you want.
  • Configure invalid-input handling so an empty or nonnumeric member produces a diagnostic or an invalid-data quality rather than a plausible zero.

Should you fix the publisher or the receiver? #

Fix the publisher when you control its output and no other subscriber depends on the string format; otherwise convert in the receiver, because that changes nothing upstream. Decide with these rules:

  • You own the publisher and its subscribers. Remove the quotation marks around the fields that are meant to be numbers. This is the cleanest fix: every consumer downstream gets the correct type with zero conversion logic. Check the other subscribers first, because a shared payload contract can break someone who parses those fields as text.
  • The payload format is fixed by a vendor or a third-party device. Convert in the receiving driver, as the Text JSON driver did in the reported case, or write the tags on an edge gateway from the MQTT JSON payload, where the gateway parses the string and publishes or writes a typed value onward.
  • Do not strip quotation marks from the whole document. The error, raw and timestamp members are text by nature; only the numeric measurement and rate are candidates for the change.
  • Do not add a transformation hop when an endpoint can do the conversion. An intermediate service adds a process to monitor and another place for the payload to fail, and it buys nothing when either end can emit or parse the number directly.

How do you run the quotation-mark test? #

Run one controlled test that changes only the quotation marks around the value member, keeping the topic, nesting and receiving point identical, and watch the same analog point go from rejected to populated. That single variable is what makes the result conclusive:

  1. Subscribe a capture client to the topic and record the payload as the publisher currently sends it, quotation marks included.
  2. Note the analog point's quality and last-update time with the string form in place. Expect it unchanged or zero-quality.
  3. Publish the same document to the same topic from a test client, changing only "value": "868.9640" to "value": 868.9640. Leave raw, pre, error, rate and timestamp exactly as they were.
  4. Watch the analog point. If it populates, the type was the fault and the decision from the previous section applies. If it still does not, capture what arrived and check the subscription and field selection before suspecting anything else.
  5. Restore the publisher's normal output until you have implemented the chosen fix deliberately, so the test does not masquerade as the repair.

How do you prove the value is freshly acquired? #

A displayed number alone proves nothing, because a point can hold its last good value after acquisition fails and a retained message can replay old data when the subscription starts. Verify freshness, not presence:

  • Send a fresh, different measurement through the normal publisher-to-broker-to-SCADA route and confirm the same point changes. For the sample above, the converted result is 868.9640, subject to the point's display precision, so a display showing fewer trailing zeros is correct, not a fault.
  • Read quality, acquisition diagnostics and update time together with the value. The payload's own timestamp is the measurement time; the point's update time is the receipt time, and they are not the same thing.
  • Publish a missing or nonnumeric value once and confirm the invalid-data behavior you configured fires, then restore valid input. A point that shows a good number through that test is holding stale data, and your conversion is not proven.

Once all three checks pass on the live path, the string-to-number problem is closed, and any future rejection with the same symptom starts at the captured payload, not at the network.

Questions asked

Why does a home-automation platform accept the same payload that the SCADA analog point rejects?

Because the conversion happens in software you do not see. Such platforms run the incoming text through a parsing layer that coerces the field to a number before it becomes a state value. The SCADA analog point in the reported installation had no such coercion step, so the raw JSON type decided the outcome.

Does Sparkplug B have this string-versus-number problem?

No. A Sparkplug B metric carries an explicit data type in its payload, so a metric published as a float arrives at the host as a float, not as text that needs conversion. The trade-off is that the publisher must build a Sparkplug payload instead of plain JSON, and the host needs a Sparkplug-capable driver.

Should the raw field with leading zeros also be converted to a number?

No, keep it as text. Converting "00868.9640" to a number discards the leading zeros and any fixed-width formatting, and numeric conversion represents the measurement, not its original layout. Keep value as the converted numeric field and map raw to a string point or leave it unparsed if the zeros carry meaning for you.

Does upgrading to MQTT version 5 change anything here?

No. Every MQTT version treats the payload as opaque application data; version 5 adds properties, reason codes and session options, not payload inspection. A quoted value is still a JSON string on arrival, so the fix stays in the publisher or in a receiver-side driver that converts text.

Keep reading

  • How-to

    How Geo SCADA publishes values to MQTT

    Geo SCADA Expert publishes outbound values as control writes to MQTT Text driver points: the topic lives in each point's Control settings and the control value becomes the payload, while the point's readback is irrelevant. Sparkplug payloads need the Sparkplug B driver. Data arriving from Node-RED proves only the inbound path.

    Edge computing and IIoT

  • Explainer

    Exporting Sparkplug B out of Geo SCADA to a historian

    No modified DDK driver will push Sparkplug B out of Geo SCADA, because the driver layer is pull-only in the outbound direction. Build the publisher on the Client API Sample DataFeeder pattern, which watches about 100,000 points per instance; for millions of points, use HSI or a database-level connector.

    Edge computing and IIoT

  • Troubleshooting

    Fixing extra characters in a PLC MQTT JSON payload

    The extra characters come from publishing a UTF-16 WSTRING to a subscriber that reads UTF-8, and from sending SIZEOF bytes of the allocated buffer instead of the text. Convert the finished JSON with JSON.Stu.ConvertUTF16toUTF8 into a STRING(2000), then publish TO_UDINT(JSON.Stu.StrLenA(ADR(utf8JsonData))) bytes. Keep the MQTT 5 properties; they declare UTF-8 but convert nothing.

    Edge computing and IIoT