CBOR: Decode Node

The CBOR: Decode Node converts data encoded in the Concise Binary Object Representation format into a JSON object.

CBOR: Decode Node

Node Properties

The CBOR: Decode Node takes the following properties …

Input

  • Input Encoding: The encoding method applied to the CBOR data you wish to decode. Options are:

    • Base64
    • Binary
    • Hex (default)
  • CBOR Input Path: (Required) A payload path to where the encoded data can be found on the payload.

Result

  • JSON Result Path: (Required) A payload path to where the decoded CBOR data, in JSON format, should be placed on the payload.

Errors

  • Error Result Path: (Optional) A payload path for where to place info about any errors that occur while attempting to decode the value at CBOR Input Path.

Read more about handling errors from this node below.

Node Example

Given the following payload …

{
  "data": "a26568656c6c6f65776f726c6466706c65617365a366656e636f6465626d656261738461436142614f61526574696d657301"
}

… and a CBOR: Decode Node with the following configuration …

  • Input Encoding: Hex
  • CBOR Input Path: data
  • JSON Result Path: working.cborDecoded

The payload after execution of the CBOR: Decode Node would look like:

{
  "data": "a26568656c6c6f65776f726c6466706c65617365a366656e636f6465626d656261738461436142614f61526574696d657301",
  "working": {
    "cborDecoded": {
      "hello": "world",
      "please": {
        "encode": "me",
        "as": ["C","B","O","R"],
        "times": 1
      }
    }
  }
}

Use Case

The CBOR: Decode Node is commonly used in conjunction with the CBOR: Encode Node as a means of reducing bandwidth usage by an Edge Compute device. See the CBOR: Encode Node use case for a detailed example.

Node Errors

In the case that the value found at the CBOR Input Path fails to parse, no value will be placed at the JSON Result Path; however, an object detailing the error will be placed at the Error Result Path if a path is provided.

Below is an example of an error stored on the payload at the path working.cborError:

{
  "working": {
    "cborError": {
      "message": "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object",
      "type": "CBOR_DECODE_NODE_ERROR"
    }
  }
}

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.