Henchway
4 years agoContributor
Match operator: match object key with special characters
Hi all,
I’m facing and issue where i would like to match some properties of an object within an array and then select a specific object key for the result.
Since my source data is Workday XML, I have namespaces prepended to the object keys.
In this match, i would like to retrieve the ‘wd:Email_Address’ element, but i believe that since i put that in quotes, it doesn’t realize that i want to declare it as variable. When i don’t do that, it will also not accept it due to the colon.
Does anyone have a suggestion on how to deal with this?
match $['wd:Worker_Data']['wd:Personal_Data']['wd:Contact_Data']['wd:Email_Address_Data'] {
 [..., { "wd:Usage_Data": { "@wd:Public": "1"}, 'wd:Email_Address' }, ...] => 'wd:Email_Address'
}
Here’s an exemplary data set that i’d like to match (the bulk before is omitted):
  "wd:Email_Address_Data": [
  {
    "wd:Email_Address": "Thomas.scheibelhofer@kapsch.net",
    "wd:Usage_Data": {
      "@wd:Public": "1",
      "wd:Type_Data": {
        "@wd:Primary": "1",
        "wd:Type_Reference": {
          "@wd:Descriptor": "Work",
          "wd:ID": [
            {
              "@wd:type": "WID",
              "$": "..."
            },
            {
              "@wd:type": "Communication_Usage_Type_ID",
              "$": "WORK"
            }
          ]
        }
      }
    },
    "wd:Email_Reference": {
      "@wd:Descriptor": "EMAIL_REFERENCE-3-7789",
      "wd:ID": [
        {
          "@wd:type": "WID",
          "$": "..."
        },
        {
          "@wd:type": "Email_ID",
          "$": "..."
        }
      ]
    },
    "wd:ID": "..."
  },
  {
    "wd:Email_Address": "test@test.test",
    "wd:Usage_Data": {
      "@wd:Public": "0",
      "wd:Type_Data": {
        "@wd:Primary": "1",
        "wd:Type_Reference": {
          "@wd:Descriptor": "Home",
          "wd:ID": [
            {
              "@wd:type": "WID",
              "$": "..."
            },
            {
              "@wd:type": "Communication_Usage_Type_ID",
              "$": "HOME"
            }
          ]
        }
      }
    },
    "wd:Email_Reference": {
      "@wd:Descriptor": "...",
      "wd:ID": [
        {
          "@wd:type": "WID",
          "$": "..."
        },
        {
          "@wd:type": "Email_ID",
          "$": "..."
        }
      ]
    },
    "wd:ID": "..."
  }
  ]
```json
Best regards
Thomas