Path

A string used to locate a node in the object tree, which consists of object property names or array indexes/conditions, starting from the root of the object to the node you are trying to find.

Examples

Assuming we have the following object:

const obj = {
  options: {
    albums: {
      showId: true,
      sortBy: 'name'
    }
  },
  artists: [
    {
      id: 3,
      name: 'A1',
      albums: [
        { id: 1, name: 'a1', year: 1990 },
        { id: 2, name: 'a2', year: 1995 },
      ]
    }
  ]
};

The you can use:

'options.albums.sortBy': to find a nested object property.

'options.albums': to find the whole 'albums' object.

'artists[0]': to find an array element by specifying the index.

'artists[id=3]': to find an array element by specifying a condition.

'artists[id=3].name': to find an object property of an array element.

'artists[id=3].albums[1]': to find a nested array element (a condition on artists, an index on albums).

'artists[id=3].albums[name=a2].year': to find the 1st artist's 2nd album's year property.

results matching ""

    No results matching ""