getUserSelection

The getUserSelection method prompts the user to choose an option from a predefined list. This is useful for gathering user input where multiple choices are available.

Request

📘

JSON-RPC 2.0

All methods in TweezerComm follow a JSON-RPC 2.0 structure. See Get Startedfor more details on how the requests are structured and sent.

To invoke this method, set the method field to getUserSelection, and include the service name and parameters as shown below.

{
    "jsonrpc":"2.0",
    "method":"getUserSelection",
    "id":"1234567890",
    "params": [
            "device",{
                "title": "Choose item:",
                "itemsKeys": ["1","2","3","4"],
                "itemsValues": ["Option1","Option2","Option3","Option4"],
                "timeout": 60
            }
        ]
}

Request Parameters

The table below describes the parameters of the request:

NameTypeDescription
titlestringMain title to display.
itemsKeysarray of stringValues used as the return keys.
itemsValuesarray of stringVisible values are presented to the user.
timeoutintTimeout duration in seconds.

Response

A successful request will return the following response:

{
    "jsonrpc": "2.0",
    "id": "1234567890",
    "result": {
        "statusCode": 0,
        "selection": "1"
    }
}

Response Parameters

The table below describes the response parameters for this method:

NameTypeDescription
statusCodeintegerOperation status (0 = success).
statusMessagestringOperation message (optional).
selectionstringThe selected key from the user.