Skip to content
Utility functions for working with line-delimited JSON ("JSON Lines")
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dir-locals.el Initial commit Apr 8, 2019
Cask Initial commit Apr 8, 2019
README.org Revise README documentation Jun 16, 2019
jsonl.el

README.org

jsonl.el

Introduction

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:

Usage

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")

Alternatives / Related Projects

  • ndjson (javascript) - streaming line delimited json parser + serializer
  • node-ld-jsonstream (javascript) - Simple and secure line delimited JSON stream parser
You can’t perform that action at this time.