Hi James,

Sharing your Nifi version would help identify the issue.

However, one thing which I encountered while working with Nifi version
1.23.2 that the processor does not like embedded comments in the
transformations. I needed to remove all the comments.

I tested yours by removing the comment and it seems to be working fine:

[
  {
    "operation": "shift",
    "spec": {
      "ids": "ids",
      "parents": "parents",
      "dates": "dates",
      "triage": "triage",
      "payload": "payload"
    }
  },
  {
    "operation": "default",
    "spec": {
      "payload": ""
    }
  }
]

Regards
--
Arvind Singh Tomar


On Mon, Feb 19, 2024 at 8:49 AM James McMahon <jsmcmah...@gmail.com> wrote:

> I have this JSON as flowfile content:
>
> {
>   "dates" : {
>     "date_file" : "20240115184407",
>     "ingested" : "20240217175748",
>     "latest_date" : "19800000",
>     "earliest_date" : "19800000",
>     "date_info" : "YYYYMMDD"
>   },
>   "parents" : {
>     "md5" : "86107362084b86ea64dc33dfde5e14ff",
>     "sha256" :
> "4ffe010f3392dddb3a880f0e60a6bf35e1e41444b7e83be0746097557d555e0f"
>   },
>   "triage" : {
>     "filetype" : "unstructured",
>     "languages" : "[\"gaelic\"]",
>     "filename" : "gaelicTest.txt"
>   },
>   "ids" : {
>     "md5" : "86107362084b86ea64dc33dfde5e14ff",
>     "sha256" :
> "4ffe010f3392dddb3a880f0e60a6bf35e1e41444b7e83be0746097557d555e0f",
>     "sku" : "00000"
>   }
> }
>
> I am trying to apply a simple JOLT transform that adds a key payload at
> the same level in my json as keys dates, parents, triage, and ids.
>
> I developed this transform - just about as simple a case you could
> possibly hope for:
> [
>   {
>     "operation": "shift",
>     "spec": {
>       "ids": "ids",
>       "parents": "parents",
>       "dates": "dates",
>       "triage": "triage",
>       "payload": "payload"
>     }
>   },
>   {
>     "operation": "default",
>     "spec": {
>       // if payload does not exist, then apply a default of null
>       "payload": ""
>     }
>   }
> ]
>
> I tested this successfully here: https://jolt-demo.appspot.com/#inception
> .
> It works.
> No big surprise - this is about as simple as it gets.
>
> Should work in nifi, right? Can't get much easier than this.
>
> But in nifi, it throws this error:
>
> JoltTransformJSON[id=4d6c3f69-a72e-16b2-8cfe-2a9adb9303c7] processor is not 
> valid: : com.bazaarvoice.jolt.exception.SpecException: Shiftr expected a spec 
> of Map type, got ArrayList
>
>
> Why? How can I get this to work in NiFi?
>
>
>
>

Reply via email to