Selecting values with wildcards

A worked sUTL example with source data, transform, expected output and runnable-original links.

sUTL · Guide · Reference · Examples

This worked example preserves its recovered source, transform and expected result. It is a static, inspectable example in Everything.

Source

{
  "name": "people list",
  "people": [
    {
      "name": "Fred",
      "title": "Mr"
    },
    {
      "name": "George",
      "title": "Rev"
    },
    {
      "name": "Harriet",
      "title": "Dr"
    }
  ]
}

Transform

{
  "names": "&@.people.*.name",
  "allnames": "&@.**.name",
  "people": "&@.people.*",
  "alsopeople": "^@.people",
  "a person": "^@.people.*",
  "allmypaths": "&~.*"
}

Expected result

{
  "names": [
    "Fred",
    "George",
    "Harriet"
  ],
  "allnames": [
    "people list",
    "Fred",
    "George",
    "Harriet"
  ],
  "people": [
    {
      "name": "Fred",
      "title": "Mr"
    },
    {
      "name": "George",
      "title": "Rev"
    },
    {
      "name": "Harriet",
      "title": "Dr"
    }
  ],
  "alsopeople": [
    {
      "name": "Fred",
      "title": "Mr"
    },
    {
      "name": "George",
      "title": "Rev"
    },
    {
      "name": "Harriet",
      "title": "Dr"
    }
  ],
  "a person": {
    "name": "Fred",
    "title": "Mr"
  },
  "allmypaths": [
    "&@.people.*.name",
    "&@.**.name",
    "&@.people.*",
    "^@.people",
    "^@.people.*",
    "&~.*"
  ]
}

Run it

Use the language site example or copy it into the playground. If the transform calls map_core or another library name, load the core distribution and compile its requirements; the full fixture retains that library context.

Full original fixture · Curated source record

Related reading

Paths · Quoting and evaluation · Libraries

Source

Adapted from the sUTL source material.

Back to sUTL · Software & Agents · All topics

View page as JSON