Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将输入JSON中的特定字段添加到JOLT规范中,以在NIFI中获得所需的输出?_Json_Apache Nifi_Jolt - Fatal编程技术网

如何将输入JSON中的特定字段添加到JOLT规范中,以在NIFI中获得所需的输出?

如何将输入JSON中的特定字段添加到JOLT规范中,以在NIFI中获得所需的输出?,json,apache-nifi,jolt,Json,Apache Nifi,Jolt,我在获取正确数组的数据时遇到问题 输入: { "type":"insert", "timestamp":1578899080000, "columns":[ { "id":1, "name":"id", "column_type":4, "value":3 }, { "id":2, "name":"title", "

我在获取正确数组的数据时遇到问题

输入:

{    "type":"insert",    "timestamp":1578899080000,    "columns":[
      {
         "id":1,
         "name":"id",
         "column_type":4,
         "value":3
       },
      {
         "id":2,
         "name":"title",
         "column_type":-1,
         "value":"mr"
       },
      {
         "id":3,
         "name":"first",
         "column_type":-1,
         "value":"todd"
       },
      {
         "id":4,
         "name":"last",
         "column_type":-1,
         "value":"graham"
       },
      {
         "id":5,
         "name":"street",
         "column_type":-1,
         "value":"5760 spring hill rd"
       },
      {
         "id":6,
         "name":"city",
         "column_type":-1,
         "value":"garden grove"
       },
      {
         "id":7,
         "name":"state",
         "column_type":-1,
         "value":"north carolina"
       },
      {
         "id":8,
         "name":"zip",
         "column_type":-1,
         "value":"81790"
       },
      {
         "id":9,
         "name":"gender",
         "column_type":-1,
         "value":"M"
       },
      {
         "id":10,
         "name":"email",
         "column_type":-1,
         "value":"todd.graham39@example.com"
       },
      {
         "id":11,
         "name":"username",
         "column_type":-1,
         "value":"purplekoala484"
       },
      {
         "id":12,
         "name":"password",
         "column_type":-1,
         "value":"paintball"
       },
      {
         "id":13,
         "name":"phone",
         "column_type":-1,
         "value":"(230)-874-6532"
       },
      {
         "id":14,
         "name":"cell",
         "column_type":-1,
         "value":"(186)-529-4912"
       },
      {
         "id":15,
         "name":"ssn",
         "column_type":-1,
         "value":"362-31-5248"
       },
      {
         "id":16,
         "name":"date_of_birth",
         "column_type":93,
         "value":"2006-07-25 05:48:01.0"
       },
      {
         "id":17,
         "name":"reg_date",
         "column_type":93,
         "value":"2004-12-05 11:26:34.0"
       },
      {
         "id":18,
         "name":"large",
         "column_type":-1,
         "value":"http://api.randomuser.me/portraits/men/39.jpg"
       },
      {
         "id":19,
         "name":"medium",
         "column_type":-1,
         "value":"http://api.randomuser.me/portraits/med/men/39.jpg"
       },
      {
         "id":20,
         "name":"thumbnail",
         "column_type":-1,
         "value":"http://api.randomuser.me/portraits/thumb/men/39.jpg"
       },
      {
         "id":21,
         "name":"version",
         "column_type":-1,
         "value":"0.6"
       },
      {
         "id":22,
         "name":"nationality",
         "column_type":-1,
         "value":"US"
       }
    ] }
期望输出:

[
   {
      "type":"insert",
      "timestamp":1578899080000,
      "id":6,
      "title":"miss",
      "first":"Amaira",
      "last":"khan",
      "street":"4524 hogan st",
      "city":"iowa park",
      "state":"ohio",
      "zip":"24140",
      "gender":"M",
      "email":"guy.mckinney53@example.com",
      "username":"blueduck623",
      "password":"office",
      "phone":"(309)-556-7859",
      "cell":"(856)-764-9146",
      "ssn":"973-37-9077",
      "date_of_birth":"1983-11-03 22:02:12.0",
      "reg_date":"2003-10-20 07:23:06.0",
      "large":"http://api.randomuser.me/portraits/men/24.jpg",
      "medium":"http://api.randomuser.me/portraits/med/men/24.jpg",
      "thumbnail":"http://api.randomuser.me/portraits/thumb/men/24.jpg",
      "version":"0.6",
      "nationality":"US"

}
]

以下规范将执行您想要的操作。
@(1,名称)
使用该值作为键

[
  {
    "operation": "shift",
    "spec": {
      "type": "[0].type",
      "timestamp": "[0].timestamp",
      "columns": {
        "*": {
          "value": "[0].@(1,name)"
        }
      }
    }
  }
]

什么是颠簸规格来获得这个输出?好,考虑接受答案让别人知道。