Paths
This page describes what a Path
is how to deal with it in the Swift library.
To navigate through the data, Scout uses paths. A path is a collection of PathElement
s (basically a wrapper around [PathElement]
).
PathElement
The current available PathElement
are exposed below.
Key
Subscript a dictionary.
String representation: a dot "." followed by the key name. Ex: .key
.
Index
String representation: an integer enclosed by square brackets. Ex: [2]
.
Subscript an array.
A negative value targets an element starting from the end.
Count
String representation: the sharp sign '#' encloded by square brackets. Ex: [#]
. Get a dictionnary or an array count.
KeysList
String representation: the sharp sign '#' encloded by curl brackets. Ex: {#}
. Get a dictionnary key names in a list.
Array slice
String representation: two integers separated by a double point character ':' and encloded by square brackets.
Slice an array between specified bounds.
No lower means the first element and no upper means the last. Ex: [1:2]
, [:1]
, [:10]
, [:]
.
A negative value targets an element starting from the end.
Dictionary keys filter
String representation: a regular expression pattern enclosed by sharp '#' signs and preceded by a dot '.' Ex: .#.*#
Filter the keys of a dictionary with a regular expression.
Brackets in the string representation
Everything between brakets will be treated as a key
.
Ex: website.(me.acme.com).name
will be treated as "website", "me.acme.com", "name".