murex Shell Docs

Command Reference: struct-keys

Outputs all the keys in a structure as a file path


struct-keys outputs all of the keys in a structured data-type eg JSON, YAML, TOML, etc.

The output is a JSON array of the keys with each value being a file path representation of the input structure’s node.


<stdin> -> struct-keys [ depth ] -> <stdout>

<stdin> -> struct-keys [ flags ] -> <stdout>


The source for these examples will be defined in the variable $example:

» set: json example={
      "firstName": "John",
      "lastName": "Smith",
      "isAlive": true,
      "age": 27,
      "address": {
          "streetAddress": "21 2nd Street",
          "city": "New York",
          "state": "NY",
          "postalCode": "10021-3100"
      "phoneNumbers": [
              "type": "home",
              "number": "212 555-1234"
              "type": "office",
              "number": "646 555-4567"
              "type": "mobile",
              "number": "123 456-7890"
      "children": [],
      "spouse": null

Without any flags set:

» $example -> struct-keys

Defining max depth and changing the separator string:

» $example -> struct-keys --depth 1 --separator '.'   

An example of a unicode character being used as a separator:

» $example -> struct-keys --depth 2 --separator ☺                                                                                                                                                           

Separator can also be multiple characters:

» $example -> struct-keys --depth 1 --separator '|||' 


See Also

This site's content is rebuilt automatically from murex's source code after each merge to the master branch. Downloadable murex binaries are also built with the website.

Last built on Thu Oct 13 08:08:18 UTC 2022 against commit ed6b6fced6b6fc609f4be93c5d3348695a762facfecf48f.

Current version is 2.11.2200 which has been verified against 16798 tests cases.