Local Storage

Store Key-Value pairs in the control box as strings.

Set Key-Value Pair

  • Function name: Method set_item under [Robot]
  • Parameters:
    1. key: [str] Key name
    2. value: [str] Value corresponding to the key
  • Return: None

Example Program

lebai:set_item("key", "value")
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "set_item", "params": [{"key": "", "value": ""}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }

Get Key-Value Pair

  • Function name: Method get_item under [Robot]
  • Parameters:
    1. key: [str] Key name
  • Return: [Item] Value corresponding to the key

Example Program

value = lebai:get_item("key")
print(value)
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_item", "params": [{"key": ""}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"value": ""}, "id": 1 }

Get All Key-Value Pairs with Specified Prefix

  • Function name: Method get_items under [Robot]
  • Parameters:
    1. prefix: [str] Key name prefix
  • Return: [Item] Key-value pair array

Example Program

values = lebai:get_items("prefix")
print(values)
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_items", "params": [{"perfix": ""}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"items": [{"key": "", "value": ""}]}, "id": 1 }