MQTT.fx with marshaler = "json"

Since months I use MQTT.fx for debugging purpose of my LoRaWAN infrastructure. I use the parameter “Payload decoded by: JSON Pretty Format Decoder”
My decoded data looks like:

  "adr" : true,
  "fCnt" : 44931,
  "fPort" : 5,
  "data" : "AQEHAj4EAAAFAgcOJA==",
  "object" : {
    "humidity" : 62,
    "light" : 0,
    "motion" : 2,
    "temperature" : 26.3,
    "vdd" : 3620

Since Chirpstack 3.11 I changed the marshaller from “json_v3” to “json”. And now the MQTT.fx looks quite ugly.

  "fPort" : 1,
  "data" : "MLABCwET",
  "objectJSON" : "{\"DecodeDataHex\":\"30b0010b0113\",\"DecodeDataObj\":{\"hwError\":false,\"lowBat\":false,\"msgID\":48,\"msgIDStr\":\"Keep alive frame\",\"statusByte\":176,\"temperatureCh1\":26.7,\"temperatureCh2\":27.5}}",
  "tags" : { },
  "confirmedUplink" : false,
  "devAddr" : "ApaCQA=="

I read “json_v3” is legacy so I want to avoid it.
But wants the right/best strategy to get a better readable MQTT output?
Change the decoder scripts?
Change MQTT.fx and use another tool?

Define ugly :wink:

In think what you mean is that the objectJSON looks different from the object in the json_v3. This is because the JSON (and Protobuf) marshaler are defined as Protobuf messages. This means that each field must be typed. Where before the object field could contain any structure (in Go), this is not the case with objectJSON. This field is typed as string and contains the object in JSON format.

This means you have to decode the objectJSON to an object yourself. See also:

Hi Brocaar

Easy readable for human periphery :grinning:

Okay. If I understand right the objectJSON is the future proof variant of the marshaler and I have to change the subscriber application of my MQTT published data.


Correct. Also note that the data of the json and protobuf marshaler is (and always) will be equal. In fact, it contains more meta-data than the legacy json_v3 option :slight_smile:

1 Like

So as per above, I’m using marshaler = “json” in the CS app server .toml configuration. Subscribing to the app server MQTT and grabbing sensor data. In Go I use json.Unmarshal to get the payload. Unfortunately to get into the obectJSON data I then have to use the gabs package to drill in further. Is there an easier way? Please see implementation snippet here:

Go Playground


I think it’s much easier to use the chirpstack-api package that includes protobuf-generated structs and unmarshal into those (you will want to use protojson if you’re still using the JSON marshaler).

Thanks I moved from MQTT and am now using the HTTP integration to push info to an HTTP server. Easier to unmarshal.