JOLT 转换:子对象至顶层对象

huangapple 未分类评论49阅读模式
英文:

JOLT transform: sub-object to top object

问题

这是您要的JSON转换结果,其中"cancelInfo"的内容被转移到了JSON的顶层:

[{
  "code": "01.11.11.111-00001",
  "version": "1",
  "inclusionDate": "2018-06-16T05:53:14+04:00",
  "publishDate": "2018-06-16T05:53:14+04:00",
  "name": "????",
  "actual": "false",
  "applicationDateStart": "2018-06-16T00:00:00+04:00",
  "applicationDateEnd": "2018-06-16T00:00:00+04:00",
  "cancelDate": "2018-06-17T00:00:00+04:00",
  "cancelReason": "????????? ???? ????????? ?????????? ??????? ????.",
  "nsiDescription": "",
  "isTemplate": "false",
  "noNewFeatures": "false"
}, {
  "code": "01.11.11.111-00002",
  "version": "1",
  "inclusionDate": "2018-06-21T04:21:14+04:00",
  "publishDate": "2018-06-21T04:21:14+04:00",
  "name": "????",
  "actual": "false",
  "applicationDateStart": "2018-06-21T00:00:00+04:00",
  "applicationDateEnd": "2018-06-22T00:00:00+04:00",
  "cancelDate": "2018-06-22T00:00:00+04:00",
  "cancelReason": "????????? ???? ????????? ?????????? ??????? ????.",
  "isTemplate": "false",
  "noNewFeatures": "false"
}]

关于如何使用Jolt进行此类转换,您可以查看Jolt的完整描述和规范文档,但是您提到您找不到它。在Jolt的官方GitHub存储库中,您可以找到详细的文档和示例:https://github.com/bazaarvoice/jolt

希望这对您有所帮助!

英文:

I use Apache NIFI. I need transform JSON in JSON with JoltTransformJSON processor.
I have JSON:

[ {
  "code" : "01.11.11.111-00001",
  "version" : "1",
  "inclusionDate" : "2018-06-16T05:53:14+04:00",
  "publishDate" : "2018-06-16T05:53:14+04:00",
  "name" : "????",
  "actual" : "false",
  "applicationDateStart" : "2018-06-16T00:00:00+04:00",
  "applicationDateEnd" : "2018-06-16T00:00:00+04:00",
  "cancelInfo" : {
    "cancelDate" : "2018-06-17T00:00:00+04:00",
    "cancelReason" : "????????? ???? ????????? ?????????? ??????? ????."
  },
  "nsiDescription" : "",
  "isTemplate" : "false",
  "noNewFeatures" : "false"
}, {
  "code" : "01.11.11.111-00002",
  "version" : "1",
  "inclusionDate" : "2018-06-21T04:21:14+04:00",
  "publishDate" : "2018-06-21T04:21:14+04:00",
  "name" : "????",
  "actual" : "false",
  "applicationDateStart" : "2018-06-21T00:00:00+04:00",
  "applicationDateEnd" : "2018-06-22T00:00:00+04:00",
  "cancelInfo" : {
    "cancelDate" : "2018-06-22T00:00:00+04:00",
    "cancelReason" : "????????? ???? ????????? ?????????? ??????? ????."
  },
  "isTemplate" : "false",
  "noNewFeatures" : "false"
} ]

How I can transform this part of JSON

  "cancelInfo" : {
    "cancelDate" : "2018-06-22T00:00:00+04:00",
    "cancelReason" : "????????? ???? ????????? ?????????? ??????? ????."
  },

In this JSON. Transform with JOLT.

[ {
  "code" : "01.11.11.111-00001",
  "version" : "1",
  "inclusionDate" : "2018-06-16T05:53:14+04:00",
  "publishDate" : "2018-06-16T05:53:14+04:00",
  "name" : "????",
  "actual" : "false",
  "applicationDateStart" : "2018-06-16T00:00:00+04:00",
  "applicationDateEnd" : "2018-06-16T00:00:00+04:00",
  "cancelDate" : "2018-06-17T00:00:00+04:00",
  "cancelReason" : "????????? ???? ????????? ?????????? ??????? ????.",
  "nsiDescription" : "",
  "isTemplate" : "false",
  "noNewFeatures" : "false"
}, {
  "code" : "01.11.11.111-00002",
  "version" : "1",
  "inclusionDate" : "2018-06-21T04:21:14+04:00",
  "publishDate" : "2018-06-21T04:21:14+04:00",
  "name" : "????",
  "actual" : "false",
  "applicationDateStart" : "2018-06-21T00:00:00+04:00",
  "applicationDateEnd" : "2018-06-22T00:00:00+04:00",
  "cancelDate" : "cancelDate" : "2018-06-22T00:00:00+04:00",
  "cancelReason" : "????????? ???? ????????? ?????????? ??????? ????.",
  "isTemplate" : "false",
  "noNewFeatures" : "false"
} ]

I can't make a JOLT specification. Tell me also where you can see its full description, I can't find it.

答案1

得分: 0

我使用这个方案来解决我的问题:

  {
    "operation": "shift",
    "spec": {
        "*": {
              "@": "",
              "cancelInfo": {
                "cancelDate": "cancelInfo_cancelDate",
                "cancelReason": "cancelInfo_cancelReason"
              }
      }
    }
  }
英文:

I use this cheme for slove my problem:

  {
    "operation": "shift",
    "spec": {
        "*": {
              "@": "",
              "cancelInfo": {
                "cancelDate": "cancelInfo_cancelDate",
                "cancelReason": "cancelInfo_cancelReason"
              }
      }
    }
  }

huangapple
  • 本文由 发表于 2020年5月29日 19:06:17
  • 转载请务必保留本文链接:https://java.coder-hub.com/62084492.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定