# Directed Paths

Access to a container or an item in a container is specified by the use of a directed path. A directed path is a string representation of how to traverse a container to identify a particular item. Directed path components always have leading and trailing spaces removed. To preserve spaces in Object names, they must be enclosed in double quote (") characters.

The minimum directed path is a name of a container.

You refer to an array element as [index]. The indexes are 0 based. [0] refers to the first item in an array, [1] to the second, etc.

You refer to an object item as: .name

The name in a JSON Object's name:value pair can essentially be any string ... and can even be empty. When parsing the reference to an item, Yate ignores leading and trailing spaces and terminates a name at a period (.), an open square bracket ([) or the end of the directed path. In order to support any character in names, they can be enclosed in double quote (") characters. A double quote character can be represented as two adjacent double quote characters. For example, a name of spaceAB"CDspace would be specified as " AB""CD ".

Sample JSON text stored in a container named sample

    [
      {
        "id" : 23,
        "location" : {
          "address" : "123 Front Street",
          "phone #" : "555-5555"
        },
        "moods" : [
          "rock",
          "blues"
        ],
        "name" : "Jack",
        "special" : true
      },
      {
        "id" : 24,
        "location" : {
          "address" : "21 Main Street",
          "phone #" : "555-2222"
        },
        "moods" : [
          "classical",
          "opera",
          "jazz"
        ],
        "name" : "Jill",
        "special" : null
      }
    ]

Example 1: sample[1].location.address
  refers to the "21 Main Street" string.
Example 2: sample[0].moods[1]
  refers to the "blues" string
Example 3: sample[1].moods
  refers to the ["classical","opera","jazz"] array.
Example 4: sample
  refers to the container.

Containers