benthos read beautified json

I have a simple json

{
    "years": [ "2018", "2019" ]
}

that I want to read with Benthos. However as this is a "beautified" json, Benthos reads each line as message. How can one read this multiline json with benthos and compactify it for further downstream processors?

input:
  file:
    paths: [./init.json]
    codec: lines/multipart

pipeline:
  processors: ??

output:
  type: stdout

The pipeline should simply print the same in stdout as jq -c ./init.json would.

>Solution :

try this:

input:
  file:
    paths: [./init.json]
    codec: all-bytes

  processors:
    - mapping: |
        root = this.format_json()

output:
  stdout:
    codec: all-bytes

Also, note that the current release is V4, where type: stdout isn’t how you specify the output. Details here.

Leave a Reply