Support Questions

Find answers, ask questions, and share your expertise

Broke nested JSON array with JOLT

New Contributor

I'm looking for breaking nested JSON file and try to flat it to fit into a SQL database.

 

Current Json:

 

{
  "content": {
    "failedPerProductLineAndReason": {
      "Product1": {
        "Downsizing licenses is not allowed": 1
      }
    }
  }
}

 

 Expected outcome: 

{
"ErrorType": "failedPerProductLineAndReason",
"product": "Product1",
"error": "Downsizing licenses is not allowed",
"quantity": 1
}

 

1 REPLY 1

Super Collaborator

Hi,

Not sure if you are looking for the exact thing but this should give you the expected output from the sample you provided:

 

[
  // Flatten an array of photo objects into a prefixed
  //  soup of properties.
  {
    "operation": "shift",
    "spec": {
      "content": {
        "*": {
          "*": {
            "*": {
              "$": "error",
              "$1": "product",
              "$2": "ErrorType",
              "@": "q"
            }
          }
        }
      }
    }
  }
]

If that helps, please accept solution. Thanks