alicia
alicia

Reputation: 37

Jolt spec for nifi - removing attributes

I am newbie in NiFi. I am trying to remove some attributes (e.g. name in Swedish and Chinese, images from description, etc.) with JoltTransformJSON, with 'limited' success. Could you please help me? Many thanks in advance! Alicia

Details as below: JoltTransformJSON properties set as:

Jolt Transformation DSL: Remove
Jolt Specification: {"name": {"sv": "", "zh": ""}, "source_type": "", "description": {"image": {"url": "", "copyright_holder":"", "license_type": ""}}}

All the attributes:

[
  {
    "id": "string",
    "name": {
      "fi": "string",
      "en": "string",
      "sv": "string",
      "zh": "string"
    },
    "source_type": {},
    "info_url": "string",
    "modified_at": "2019-12-27T16:34:17.896Z",
    "location": {
      "lat": {},
      "lon": {},
      "address": {
        "street_address": "string",
        "postal_code": "string",
        "locality": "string"
      }
    },
    "description": {
      "intro": "string",
      "body": "string",
      "images": [
        {
          "url": "string",
          "copyright_holder": "string",
          "license_type": {}
        }
      ]
    },
    "tags": [
      {
        "id": "string",
        "name": "string"
      }
    ],
    "where_when_duration": {
      "where_and_when": "string",
      "duration": "string"
    }
  }
]

The problem is that transformation (removing specified fields) is not performed. The expected result should be:

    "id": "string",
    "name": {
      "fi": "string",
      "en": "string"
      },
    "info_url": "string",
    "modified_at": "2019-12-27T16:34:17.896Z",
    "location": {
      "lat": {},
      "lon": {},
      "address": {
        "street_address": "string",
        "postal_code": "string",
        "locality": "string"
      }
    },
    "description": {
      "intro": "string",
      "body": "string"
        }
      ]
    },
    "tags": [
      {
        "id": "string",
        "name": "string"
      }
    ],
    "where_when_duration": {
      "where_and_when": "string",
      "duration": "string"
    }
  }

How can I remove unwanted fields? Any help is highly appreciated.

Upvotes: 0

Views: 1612

Answers (1)

Ben Yaakobi
Ben Yaakobi

Reputation: 1668

According to your expected result, your wanted jolt specification is:

{
  "name": {
    "sv": "",
    "zh": ""
  },
  "source_type": "",
  "description": {
    "images": ""
  }
}

Upvotes: 0

Related Questions