Cloud

json_array

Consumes a stream of one or more JSON elements within a top level array.

Use this scanner to read exports whose top-level JSON structure is an array, such as logs or bulk exports, or to break a large file of many objects into one message per element. The scanner decodes elements one at a time, so it doesn’t load the whole array into memory.

The input must be one JSON array, or several arrays one after another, such as [1,2][3]. The scanner fails with an error if the input doesn’t start with [, or if anything other than another array follows a closing ]. Each element can be any JSON value, and becomes one message that contains the element’s JSON.

Suppose you have a file events.json:

events.json
[
  {"event": "login", "user": "alice"},
  {"event": "logout", "user": "bob"},
  {"event": "purchase", "user": "carol", "amount": 42}
]

The configuration to process this file is:

input:
  file:
    paths: [ "./events.json" ]
    scanner:
      json_array: {}

Result: Each event in the array is processed as a separate message.

Fields

The json_array scanner has no required fields. You declare it as {} in your config.

json_array: {}