Skip to content
Alexis Bridoux edited this page Oct 15, 2025 · 2 revisions

A path is provided to a command (such as read or set) to target specific areas in the data.

Path Elements

A path is composed of path elements in a specific order, which are exposed below.

Name Role Representation Example
Key Subscripts a dictionary A dot followed by the key name. .key
Literal Key A key with dots A key with dots enclosed by brackets. .(key.with.dots)
Index Subscripts an array An integer enclosed by square brackets. [2]
Count Get a dictionary or an array count The sharp sign enclosed by square brackets. [#]
Keys List Get a dictionary key names in a list The sharp sign enclosed by curl brackets. {#}
Array Slice Slice an array between specified bounds Two integers separated by a double points character and enclosed by square brackets. A negative value targets an element starting from the end. [1:2], [:1], [:-2]
Dictionary Keys Filter Filter the keys of a dictionary with a regular expression A regular expression enclosed by sharp signs and preceded by a dot. .#.*#

Invalid Path

If a provided to a command is invalid, the command will return an error with a proper message. A path can be invalid for several reasons. For instance:

  • A given key does not exist in a dictionary.
  • An index is greater than an array element's count.
  • A special element is not used properly.

For instance the operation using the read command will return an error because the key "score" does not exist in Tom's dictionary.

scout read "Tom.score"

When that's possible, the program will display a message to offer another possible key name. For instance the command

scout read "Tom.heiht"

will return an error but will also inform that the key 'height' is close to the 'heiht' word.

Array Subscripting

It's possible to access an element in an array by specifying its index. When the index is negative, this targets an element starting from the end of the array.

This table gives an example with an example 'ducks' array composed of 5 strings.

'ducks' array
[
  "Riri",
  "Fifi",
  "Loulou",
  "Donald",
  "Daisy"
]
"Riri" "Fifi" "Loulou" "Donald" "Daisy"
0 1 2 3 4
-5 -4 -3 -2 -1
  • ducks[1] targets "Fifi"
  • ducks[-2] targets "Donald"

Clone this wiki locally