Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

How to get column value of key in JOLT

Explorer

I'm looking for breaking following nested JSON file and transform it into a SQL prepared format.

 

Input JSON file:

 

 

 

{
  "Product1": {
    "Purchase": 31
  },
  "Product2": {
    "Purchase": 6213,
    "Cancel": 1988,
    "Change": 3702,
    "Renewal": 5934
  }
}

 

 

 

Desired output: 

 

 

 

[
  {
    "product": "Product1",
    "Purchase": 31
  },
  {
    "product": "Product2",
    "Purchase": 6213,
    "Cancel": 1988,
    "Change": 3702,
    "Renewal": 5934
  }
]

 

 

1 REPLY 1

Super Collaborator

 

Hi,

 

Try the following:

 

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": "[#2].&",
        "$": "[#2].product"
      }
    }
  }
]

 

If that helps please accept solution.

Thanks

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.