Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How do I use Jolt to json array to nested json?

avatar
New Contributor

Hi,

I am new to NiFi (1.14) and trying to use the JOLTTransform processor to transform input json (flat) to nested json. Could not able to fix with JOLT Schema. kindly help me on this. 

GetFile --->JOLTTranform-->PutFile

The Input Json is 

[
  {
    "executionTime": "2244",
    "processorId": "3ef03f9c-b42c-4c4e-9d5f-d14878bb2c84",
    "filename": "Trading",
    "processStartTime": "2021-07-26 16:31:19",
    "processSQL": "TradingDetails.sql",
    "executionFetchTime": "2049",
    "sourceCountValue": "5076",
    "startTime": "1627297279651",
    "processGroupName": "Trading"
  },
  {
    "ProcessEndTime": "2021-07-26 16:31:29",
    "completedTime": "1627297289412",
    "processDuration": "0",
    "destCountValue": "5076",
    "tableName": "TRADINGDETAILS"
  },
  {
    "ProcessEndTime": "2021-07-26 16:31:29",
    "completedTime": "1627297289412",
    "processDuration": "0",
    "destCountValue": "5076",
    "tableName": "CUSTTRADINGDETAILS"
  }
]


 and the expected output json is

{
  "Trading": {
    "Source": {
      "executionTime": "2244",
      "processorId": "3ef03f9c-b42c-4c4e-9d5f-d14878bb2c84",
      "filename": "Trading",
      "processStartTime": "2021-07-26 16:31:19",
      "processSQL": "TradingDetails.sql",
      "executionFetchTime": "2049",
      "sourceCountValue": "5076",
      "startTime": "1627297279651",
      "processGroupName": "Trading"
    },
    "Destination": {
      "TRADINGDETAILS": {
        "ProcessEndTime": "2021-07-26 16:31:29",
        "completedTime": "1627297289412",
        "processDuration": "10",
        "destCountValue": "5076",
        "tableName": "TRADINGDETAILS"
      },
      "CUSTTRADINGDETAILS": {
        "ProcessEndTime": "2021-07-26 16:31:29",
        "completedTime": "1627297289412",
        "processDuration": "10",
        "destCountValue": "5076",
        "tableName": "CUSTTRADINGDETAILS"
      }
    }
  }
}

 Thanks in advance.

1 REPLY 1

avatar
Expert Contributor

Hello

 

This is not a NiFi problem, you may try to use some online tool to help

 

https://jolt-demo.appspot.com/#inception