spath command: Overview, syntax, and usage

The SPL2 spath command extracts information from the XML and JSON structured data formats.

The SPL2 spath command extracts information from the XML and JSON structured data formats.

Use these links to quickly navigate to the main sections in this topic:

Syntax

The required syntax is in bold.

spath

[input=field]

[output=field]

[path="path"]

Required parameters

Optional parameters

path

Syntax: "path"

Description: The location path to the value that you want to extract, expressed in dot ( . ) notation. The path must be enclosed in quotation marks.

A location path is composed of one or more location steps, separated by periods. An example of this is "emea.europe.pl". A location step is composed of a field name and an optional index surrounded by curly brackets. The index can be an integer, to refer to the position of the data in an array (this differs between JSON and XML), or a string, to refer to an XML attribute. If the index refers to an XML attribute, specify the attribute name with an @ symbol.

If path is omitted, do not specify an output field. The spath command runs in "auto-extract" mode. In "auto-extract" mode, the command finds and extracts all the fields in the input value, subject to any character read limits. The default limit is 5000 characters.

If path is provided and an output field is not specified, the value of the path is extracted to a field with same name as the path. Otherwise the value of the path is placed in the field specified in the output

Note: If you specify an output field, you must specify a path.

input

Syntax: field

Description: The field to read in and extract values from.

Default: _raw

output

Syntax: field

Description: The value extracted from the path is written to this field name. When you specify an output field, you must a path.

Default: The value for the path becomes the field name for the extracted value.

Usage

The following sections contain information to help you understand and use the SPL2 spath command.

See also

spath command

spath command: Examples