murex Shell Docs

Data-Type Reference: jsonl

JSON Lines (primitive)

Description

The following description is taken from jsonlines.org:

JSON Lines is a convenient format for storing structured data that may be processed one record at a time. It works well with unix-style text processing tools and shell pipelines. It's a great format for log files. It's also a flexible format for passing messages between cooperating processes.

Examples

Example JSON lines documents taken from jsonlines.org

Tabulated data

["Name", "Session", "Score", "Completed"]
["Gilbert", "2013", 24, true]
["Alexa", "2013", 29, true]
["May", "2012B", 14, false]
["Deloise", "2012A", 19, true] 

This format is equatable to generic and csv.

Nested objects

{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]}
{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
{"name": "May", "wins": []}
{"name": "Deloise", "wins": [["three of a kind", "5♣"]]}

Detail

Concatenated JSON

Technically the jsonl Unmarshal() method supports Concatenated JSON, as described on Wikipedia:

Concatenated JSON streaming allows the sender to simply write each JSON object into the stream with no delimiters. It relies on the receiver using a parser that can recognize and emit each JSON object as the terminating character is parsed. Concatenated JSON isn't a new format, it's simply a name for streaming multiple JSON objects without any delimiters.

The advantage of this format is that it can handle JSON objects that have been formatted with embedded newline characters, e.g., pretty-printed for human readability. For example, these two inputs are both valid and produce the same output:

Single line concatenated JSON

{"some":"thing\n"}{"may":{"include":"nested","objects":["and","arrays"]}}

Multi-line concatenated JSON

{
  "some": "thing\n"
}
{
  "may": {
    "include": "nested",
    "objects": [
      "and",
      "arrays"
    ]
  }
}

...however in murex's case, only single line concatenated JSON files (example 1) are supported; and that is only supported to cover some edge cases when writing JSON lines and a new line character isn't included. The primary example might be when generating JSON lines from inside a for loop.

This behavior is also described on GitHub in issue #141.

More information

This format is sometimes also referred to as LDJSON and NDJSON, as described on Wikipedia.

murex's json data-type document also describes some use cases for JSON lines.

Default Associations

Supported Hooks

See Also

This site is rebuilt weekly, the content is automatically generated from murex's source code. Last built on Mon May 25 06:11:51 UTC 2020 against commit aa3f3b7aa3f3b7e471543754fdcaf910d4920cad9112b91. Downloadable murex binaries are also built weekly. Current version is 0.48.0120 BETA which has been verified against 29375 tests.