Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading