简体   繁体   English

JSON 使用 JOLT 进行转换

[英]JSON Transformation using JOLT

I would like to transform the below input JSON using JOLT.我想使用 JOLT 转换以下输入 JSON。 what will be the JOLT Spec? JOLT 规范是什么?

INPUT JSON--输入 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.基本上,Jolt SPEC 应包含 HTML 标签以显示图像,但 output 除外。 Can this be achieved using a jolt?这可以通过摇晃来实现吗? Is this feature is provided by the jolt library?这个功能是由 jolt 库提供的吗?

While the expected output is not presented in JSON format, the desired spec presumably might be like虽然预期的 output 未以 JSON 格式显示,但所需的规格可能类似于

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

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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