jsonapache-nifiapache-nifi-registry

Convert flow file contents of ExecuteStreamCommand to Json format


Within my Nifi workflow, I am executing my Python script using ExecuteStreamCommand and at the end of my script, I am using json.dump to dump my results into Json format. My goal is to extract key, values from this json object and use it in the next processor (PutDatabaseRecord). For this purpose, I have attached AttributestoJson processor right after ExecuteStreamCommand but the result of AttributetoJson processor is only showing me the attribute name and not its value.

Also, the content type of the ExecuteStreamCommand processor is of application/avro-binary and I am having hard time converting into other formats.

Result of ExecuteStreamCommand

Result of AttributestoJson


Solution

  • ExecuteStreamCommand writes all output to the content of the outgoing FlowFile, not to attributes. So it appears your FlowFile content already contains the JSON object, and you should be able to put it directly into PutDatabaseRecord (with a JsonTreeReader to read it in). You can also use UpdateAttribute to set mime.type to application/json to make it easier to view / manipulate downstream.