メイン コンテンツをスキップする

avpath - ロケーションパス

avpathで項目を選択するには、ロケーションパスを使用します。ロケーションパスは、1つ以上のロケーションステップで構成されます。
  • ロケーションステップは、1つのドットまたは2つのドットで始めます:

    構文

    ロケーション

    .property

    コンテキスト項目の直下でプロパティを探します

    ..property

    コンテキスト項目の下の階層からプロパティを探します

    でご覧ください。

    コンテキスト項目自体を探します

  • プロパティの正確な名前の代わりにワイルドカード記号を使用できます:

    構文

    ロケーション

    .*

    コンテキスト項目の直下にあるプロパティをすべて探します

    ..*

    コンテキスト項目の下深くにあるプロパティを探します

  • avpathを使用すると、いくつかのプロパティを結合できます:

    構文

    ロケーション

    (.property1 | .property2 | .propertyN)

    コンテキスト項目の直下でproperty1、property2、propertyNを探します

    (.property1 | .property2.property2_1.property2_1_1)

    locates .property1、.property2.property2_1.property2_1_1 items

ロケーションパスには、絶対パスまたは相対パスを使用できます。ロケーションパスがルート(^)で始まり、絶対ロケーションパスを使っている場合、ロケーションパスはルート項目から始まります。

Avroデータの例(サブレコード - 顧客のリストが含まれているAvroレコード):

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"
      }
    ]
  };
"""

ロケーションパスの例:

// 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' ]

このページは役に立ちましたか?

このページまたはコンテンツに、タイポ、ステップの省略、技術的エラーなどの問題が見つかった場合は、お知らせください。改善に役立たせていただきます。