简体   繁体   中英

JSON Transformation using JOLT

I would like to transform the below input JSON using JOLT. what will be the JOLT Spec?

INPUT JSON--

[
  {
    "Bank": [
      {
        "id": "101",
        "PuneBranch": [
          {
            "id": "449",
            "address": "Wakad",
            "IFSC": "IEC_62196_T1",
            "MICR": "123"
          },
          {
            "id": "450",
            "address": "Hinjewadi",
            "IFSC": "IEC_62196_T2",
            "MICR": "456"
          }
        ]
      },
      {
        "id": "102",
        "BangaloreBranch": [
          {
            "id": "451",
            "address": "Whitefield",
            "IFSC": "IEC_62196_T3",
            "MICR": "789"
          },
          {
            "id": "452",
            "address": "EC",
            "IFSC": "IEC_62196_T4",
            "MICR": "012"
          }
        ]
      }
    ]
  }
]

Expected Output--

Bank 1
ID: 101

🏦PuneBranch 1
id: 449
address: Wakad
IFSC: IEC_62196_T1
MICR: 123

🏦PuneBranch 2
id: 450
address: Hinjewadi
IFSC: IEC_62196_T2
MICR: 456

Bank 2
ID: 102

🏦BangaloreBranch 1
id: 451
address: Whitefield
IFSC: IEC_62196_T3
MICR: 789

🏦BangaloreBranch 2
id: 452
address: EC
IFSC: IEC_62196_T4
MICR: 012

Basically, Jolt SPEC should contain HTML tags to show the images and excepted output. Can this be achieved using a jolt? Is this feature is provided by the jolt library?

While the expected output is not presented in JSON format, the desired spec presumably might be like

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "*": ""
        }
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": {
        " Bank": "=intSum(@(1,id),-100)",
        " id": "=(@(1,id))"
      }
    }
  },
  {
    "operation": "remove",
    "spec": {
      "*": {
        "id": ""
      }
    }
  },
  {
    "operation": "sort"
  }
]

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM