0

I have following JSON data . I want to transform following data by Jolt nifi processor into result data

{
  "alert_array": {
    "alerts": [
      {
        "alertId": "alt001",
        "severity": "High",
        "alert_type": "Alert"
      },
      {
        "alertId": "alt002",
        "severity": "High",
        "alert_type": "Alert"
      }
    ]
  }
}

result data

{
  "alert_array": [
    {
      "Id": "alt001",
      "speed": "High",
      "type": "Alert"
    },
    {
      "Id": "alt002",
      "speed": "High",
      "type": "Alert"
    }
  ]
}

please help to write spac of jolt transformation

1 Answer 1

1

If you wouldn't rename the attributes, then using

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "*": "&2[&]"  // &2 represents going two levels up to get the literal "alert_array"
        }
      }
    }
  }
]

would suffice.

the demo on the site http://jolt-demo.appspot.com/ is

enter image description here

But in your case, you need to qualify each one individually such as

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "*": {
            "alert*": "&3[&1].&(0,1)",
            "severity": "&3[&1].speed",
            "alert_*": "&3[&1].&(0,1)"
          }
        }
      }
    }
  }
]

the demo on the site http://jolt-demo.appspot.com/ is

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.