Data Conversion Using a JSON Query Node

This guide assumes familiarity with the basics of the editor (Bixby Home Studio Basics).

In this guide, you'll learn how to use a JSON Query node by designing an action flow for the command:

"Increase the volume of the speaker by 25%"

You must get the result of a command and give the user the information for the command executed. Sometimes the output of nodes (responses) are in JSON format. To extract information from these responses, you can use the JSON Query node.

For example, after executing the voice command "Increase the volume of the speaker by 25%", the output (response) is shown below. You can extract the status information with a JSON Query node.

{
    "results": [
        {
            "id": "6a2e9434-5b19-47s0-92a8-685de69106a3",
            "status": "ACCEPTED"
        }
    ]
}

JSON Query Node

JSON query node

The JSON Query node parses and extract values or objects from the JSON response, which allows you to convert the data into a usable format.

Parameters in JSON query node

Input Parameters

The JSON Query node takes in the following input parameters:

  • Node trigger: Specifies the intent you want to trigger with the JSON Query action.
  • JSON object: Specifies the input JSON object.

Node Configuration

You can configure the node with:

  • Pointer: Pointer configuration can select a value by the JSON Pointer specification.
  • Data type: The Output Node value type can be set to Boolean, Integer, Number, Object, Duration, ColorMap, String or Vocab.

Output Parameters

The JSON Query node outputs the following parameters:

  • Main: Specifies the intent you want triggered after the processing.
  • Node Value: Specifies the output value of the node.

Configuration Parameter Pointer

The pointer defines the string syntax for identifying a specific value in a JSON object.

You can see an example below:

Pointer usage example

Example

The example graph below shows the action flow of using a JSON Query node:

  1. The user utterance "Set the SwitchLevel to 25". This command executes the SmartThings capability POST command. (For more information, see Sending A SmartThings command with an argument.)
  2. For SwitchLevel POST command, the server responds with JSON:
{
    "results": [
        {
            "id": "6a2e9434-5b19-47s0-92a8-685de69106a3",
            "status": "ACCEPTED"
        }
    ]
}

POST Command Response JSON

  1. To select the "status" property of a result, you can use "/results/0/status" by JSON pointer specification.
  2. If this is a success, use the JSON Query node to parse the status property from the response JSON.
  3. Compare the status property output by the JSON Query node to the string "ACCEPTED".
  4. If the comparison is true, go to a Response: Success node; otherwise, go to a Response: Execution Failed node.

Action Flow for JSON Query Node