flatten command usage
Flattening nested objects
The flatten
command can flatten only the first level of an object. For example, when an object such {a: {b: 2}}
is flattened a field called a
is created with a value {b: 2}
.
To flatten nested objects, use the expand
command with the flatten
command.
For an example of how these two commands are used together, see flatten command examples and expand command examples.
Field order in the output
When you flatten the values in an object, fields are created in the search results. The order of the fields displayed in the output is lexicographical. Lexicographical order means that numbers come before letters and uppercase letters come before lowercase letters.
For example, suppose you have the following object:
{name: "Akashi-Kaikyo Bridge", length: 12800, city: "Kobe", country: "Japan", Opened: 1998}
When the object is flattened, the order of the fields are rearranged to this:
- Opened
- city
- country
- length
- name
The output looks like this:
Opened | city | country | length | name |
---|---|---|---|---|
1998 | Kobe | Japan | 12800 | Akashi-Kaikyo Bridge |
To learn more about lexicographical order, see Lexicographical order in the SPL2 Search Manual.
See also
flatten command syntax details | flatten command examples |
This documentation applies to the following versions of Splunk® Cloud Services: current
Feedback submitted, thanks!