This library contains some utility functions to simplify working with line-delimited JSON (JSONL). Sometimes called “newline-delimited JSON” or “JSON lines”, line-delimited JSON is a format for encoding multiple JSON values within a single file:
{"foo": "bar"}
{"baz": "bat"}
These files are not valid JSON, but serve as a more suitable format for streaming or logging structured data.
Read about JSONL:
Use `jsonl-append-value` to log an arbitrary JSON value:
(jsonl-append-value "~/logging.jsonl" `((hostname . ,(s-trim (shell-command-to-string "hostname")))
(current_value . 42)
(other_data . ((list . [10 20 30])
(note . "just a note")))
(timestamp . ,(format-time-string "%Y-%m-%dT%T"))))
`loggin.jsonl` will then have the following value appended to it:
{"hostname":"devbox","current_value":42,"other_data":{"list":[10,20,30],"note":"just a note"},"timestamp":"2019-04-07T23:13:15"}
To read all values from a file:
(jsonl-read-from-file "~/logging.jsonl")
- ndjson (javascript) - streaming line delimited json parser + serializer
- node-ld-jsonstream (javascript) - Simple and secure line delimited JSON stream parser