Routing part of a message

A JsonDemuxRouter directs a subset of an incoming message (payload) to a new slot so that links may redirect the JSON to be handled by another component. This procedure provides an example of routing part of a message.
Prerequisites: The following instructions assume that you have an incoming message (payload) with the following key value pairs: “hue”, “sat”, “bri”, “on”.
{
  "hue": 43211,
  "sat": 254,
  "bri": 254,
  "on": true
}

Perform the following steps:
  1. Open the palette, expand Inbound > Routers and drag a JsonDemuxRouter component to a desired location in the station.
  2. Open the JsonDemuxRouter’s Property Sheet by double-clicking the router.
    The property sheet view displays.
    Image
     
    NOTE: Enabling Learn Mode adds a dynamic slot on input. This procedure documents how to add the slot manually.
     
  3. Manually add a baja:double slot by opening the AX Slot Sheet view, or by simply right-clicking the sheet and clicking Add Slot.
    An Add Slot window opens for either method, as shown below.
    Adding a slot from the Slot Sheet View Adding a slot using the Action menu
    Image Image
  4. To add the slot to the JsonDemuxRouter component, give the slot a name (“hue” for this example), choose Type: baja:Double and click OK.
    The new slot is added.
  5. In the Wire Sheet view, connect the schema output to the JsonDemuxRouter component’s Route slot.
    The following image shows a Wire Sheet view of components routing part of an incoming message to the slot for onward processing. The slot that you add must match the key name, to select that key, and should be either Boolean, Numeric or String to match the JSON value.
    Image
    Once the JsonDemuxRouter component has a slot of type baja:Double named "hue", it passes the hue to expose the value “43211” for use in the station.
 
NOTE: To extract nested JSON objects, add a string with an appropriate name, for example, a demuxed string named ‘data’ could contain this entire nested object:
{
 "type" : "line", 
  "data" : 
  { 
    "labels" : ["Sunday", "Monday"], 
    "values" : [ 1, 2 ] 
  } 
}