Skip to main content

Aliases

  • json.getpath

Arguments

table
required
Root table to read from. The function requires this argument to be a table.
string | table
required
Path to follow. A string is split on dots; integer string tokens are read with raw array indexing. A table path uses its array entries from 1 with #path as keys.
any
Fallback value returned when traversal reaches nil or a non-table before the path is complete.

Returns

any | nil
Value at the requested path. If the path is missing, returns defaultValue when it was provided, otherwise nil.

Example

Read a nested table value from a dotted string path or an array table of keys.