Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

JOLT Transform expression to create new items based on a given property

Highlighted

JOLT Transform expression to create new items based on a given property

New Contributor

If I have the following object

[
  {
    "municipio": 4213005,
    "_2": 16386,
    "_7": 1,
    "_21": 6259017
  },
  {
    "municipio": 3519402,
    "_2": 24581,
    "_7": 2,
    "_21": 13276890
  }
]

And I wish the following output

[
  {
    "localidade": 4213005,
    "_2": 16386
  },
  {
    "localidade": 4213005,
    "_7": 1
  },
  {
    "localidade": 4213005,
    "_21": 6259017
  },
  {
    "localidade": 3519402,
    "_2": 24581
  },
  {
    "localidade": 3519402,
    "_7": 2
  },
  {
    "localidade": 3519402,
    "_21": 13276890
  }
]

For now, I have the following JOLT

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "_7": "[#2].valor",
        "_21": "[#2].valor",
        "_41": "[#2].valor",
        "municipio": "[].localidade"
      }
    }
  }
]

But I'm in trouble to get my desired output. Which JOLT should I use to get the resulting JSON ?