Sparkplug-payload ts/js client library - DBIRTH properties

I’m not sure if this is the correct place but I’m using sparkplug-payload library in node.js. I have a question regarding sending properties on DBIRTH msg. The specification calls for two arrays I found the following example

"properties": {
        "keys": [
          "documentation"
        ],
        "values": [
          {
            "type": 12,
            "string_value": "my documentation"
          }
        ]

Using the above causes “TypeError: Cannot read properties of undefined (reading ‘toUpperCase’)”

But sparkplug-payload library seems more than happy with the following. Can I assume this is the correct way to pass properties? Thanks

 {
    "timestamp": 1465577611580,
    "seq": 0,
    "metrics": [
        { 
            "name":  "outdoor_pallet_area/externalTemperature",
            "value": 14.1,
            "type": "Float",
            "properties": {
                "engUnits": {
                    "type": "String",
                    "value": "C"
                },
                "devEUI" : {
                  "type": "String",
                  "value": "A81758FFFE03757F"
              }
            }
        },
        { 
            "name": "outdoor_pallet_area/humidity",
            "value": 88,
            "type": "UInt16",
            "properties": {
                "engUnits": {
                    "type": "String",
                    "value": "%RH"
                },
                "devEUI" : {
                  "type": "String",
                  "value": "A81758FFFE03757F"
                }
            }
        }
    ]
}

So this is always a bit confusing, but what you are displaying is a JSON representation of a Sparkplug payload. Neither of the examples are really payloads as they would be on the wire. So, where exactly are you getting representations of payloads? At the end of the day, the specification is correct and really the only way to do it on the wire. This portion of the proto file is what basically forces this to be the case:


    message PropertySet {
        repeated string        keys     = 1;         // Names of the properties
        repeated PropertyValue values   = 2;
        extensions                      3 to max;
    }

So, in the binary encoded payload it must be two arrays. The current Sparkplug specification doesn’t have a JSON schema to denote how payloads must be represented in JSON. This is something that will be addressed in Sparkplug 4.

Thanks and apologies I didn’t make myself clear.

I’m using sparkplug.encodePayload(payload) where payload is the JSON the second example above as you’ve pointed out JSON isn’t what’s on the wire.

I’m just wanting to conform to the specification. I want in the DBIRTH to pass engineering units and the unique id of each wireless sensor of which there can be 100s of sensors with multiple metrics per sensor. There doesn’t seem to be a sparkplug b validator and I don’t have anything to test against as it’s just POV at this stage…