Skip to main content

avpath - Location path

To select items in avpath, you use a location path. A location path consists of one or more location steps.
  • Location steps start with a dot or two dots:

    Syntax

    Location

    .property

    locates property immediately descended from context items

    ..property

    locates property deeply descended from context items

    .

    locates context items themselves

  • You can use the wildcard symbol instead of the exact name of the property:

    Syntax

    Location

    .*

    locates all properties immediately descended from context items

    ..*

    locates all properties deeply descended from context items

  • avpath allows you to join several properties:

    Syntax

    Location

    (.property1 | .property2 | .propertyN)

    locates property1, property2, propertyN immediately descended from context items

    (.property1 | .property2.property2_1.property2_1_1)

    locates .property1, .property2.property2_1.property2_1_1 items

Your location path can be absolute or relative. If the location path starts with the root (^) you are using an absolute location path — your location path begins from the root items.

Example of Avro data (an Avro record containing a list of sub-records - customers):

var doc =
"""
  {
    "customers" : [
      {
        "id": "1",
        "Firstname": "Quentin",
        "Lastname": "Novo",
        "Address": { "Street" : "South Roosevelt Drive" },
        "RegistrationDate": "20/01/2015",
        "Revenue": "55239",
        "States": "AZ"
      },
      {
        "id": "2",
        "Firstname": "Kip",
        "Lastname": "Von Celaeno",
        "Address": { "Street" : "Carpinteria Avenue" },
        "RegistrationDate": "19/05/2016",
        "Revenue": "78148",
        "States": "NC"
      },
      {
        "id": "3",
        "Firstname": "Beau",
        "Lastname": "Dash",
        "Address": { "Street" : "Corona Del Mar" },
        "RegistrationDate": "28/09/2009",
        "Revenue": "77912",
        "States": "CT"
      }
    ]
  };
"""

Example of location path:

// find all customers addresses
avpath.select(doc, ".customers.Address")
// [{ Street : 'South Roosevelt Drive' }, { Street : 'Carpinteria Avenue' }, { Street : 'Corona Del Mar' }]

// find all customers address streets
avpath.select(doc, ".customers.Address.Street")
// ['South Roosevelt Drive', 'Carpinteria Avenue', 'Corona Del Mar' ]

// find all streets in customers*
avpath.select(doc, ".customers..Street")
// ['South Roosevelt Drive', 'Carpinteria Avenue', 'Corona Del Mar' ]

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!