jsonfile

Queries data from a line-delimited JSON file.

Command properties

PropertyValue
Command typeDriver query
Required permissionLocal file read permission
License usageCounted
Parallel executionNot supported
Distributed executionNot supported

Syntax

jsonfile [offset=INT] [limit=INT] [overlay={t|f}] PATH

Options

offset=INT
Number of records to skip.
limit=INT
Maximum number of records to retrieve.
overlay={t|f}
When set to t, retains the original data while overwriting with parsed key-value pairs when an additional parser is applied. When set to f or not specified, only the parsed key-value pairs are output instead of the original.

Target

PATH
Path to the JSON file. The file must be a text file where each line is a JSON object. Wildcards (*) are supported. Files with a .gz extension are automatically decompressed.

Output fields

FieldTypeDescription
(JSON key)autoFields automatically mapped from JSON object key-value pairs
_filestringOriginal file name
_timetimestampTimestamp parsed from JSON or the file modification time

Error codes

Parsing errors
Error codeMessageDescription
10902-File path not specified
10900-File does not exist or cannot be read
10901-Parent directory does not exist or cannot be read
10903-File access denied

Description

The jsonfile command queries data from a text file where each line separated by CR LF or LF contains JSON. Each line's JSON object is mapped to one record, and JSON key-value pairs are automatically converted to Logpresso types.

Files that include a BOM (Byte Order Mark) are automatically recognized.

Examples

  1. Query a JSON file

    jsonfile /opt/logpresso/data/events.json
    

    Queries all data from the line-delimited JSON file.

  2. Query with a limit on record count

    jsonfile offset=100 limit=50 /opt/logpresso/data/events.json
    

    Skips the first 100 records and retrieves 50 records.