jsonl
JSON Lines
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.
Example JSON lines documents taken from jsonlines.org
["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
.
{"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♣"]]}
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 is resolved in the new data-type parser jsonc
(Concatenated JSON). See line below.
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.
json-lines
jsonl
jsonlines
ldjson
murex_history
ndjson
application/json-lines
application/jsonl
application/jsonlines
application/ldjson
application/ndjson
application/x-json-lines
application/x-jsonl
application/x-jsonlines
application/x-ldjson
application/x-ndjson
text/json-lines
text/jsonl
text/jsonlines
text/ldjson
text/ndjson
text/x-json-lines
text/x-jsonl
text/x-jsonlines
text/x-ldjson
text/x-ndjson
Marshal()
SupportedReadArray()
Works with JSON arrays. Maps are converted into arraysReadArrayWithType()
Works with JSON arrays. Maps are converted into arrays. Element data type is json
ReadIndex()
Works against all properties in JSONReadMap()
Not currently supported.ReadNotIndex()
Works against all properties in JSONUnmarshal()
SupportedWriteArray()
Supportedcast
): Alters the data-type of the previous function without altering its outputforeach
): Iterate through an array[[ Element ]]
): Outputs an element from a nested structureopen
): Open a file with a preferred handlerformat
): Reformat one data-type into another data-typeruntime
): Returns runtime information on the internal state of Murex*
(generic): generic (primitive)csv
: CSV files (and other character delimited tables)hcl
: HashiCorp Configuration Language (HCL)json
: JavaScript Object Notation (JSON)jsonc
: Concatenated JSONtoml
: Tom’s Obvious, Minimal Language (TOML)yaml
: YAML Ain’t Markup Language (YAML)ReadIndex()
(type): Data type handler for the index, [
, builtinReadNotIndex()
(type): Data type handler for the bang-prefixed index, ![
, builtinReadArray()
(type): Read from a data type one array element at a timeWriteArray()
(type): Write a data type, one array element at a timeReadMap()
(type): Treat data type as a key/value structure and read its contentsMarshal()
(type): Converts structured memory into a structured file format (eg for stdio)Unmarshal()
(type): Converts a structured file format into structured memoryThis document was generated from builtins/types/jsonlines/jsonlines_doc.yaml.
This site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Tue Dec 10 22:56:57 UTC 2024 against commit 60f05a260f05a227caf73dd5b3478e3cb3f4bb24e46745b.
Current version is 6.4.1005 (develop) which has been verified against tests cases.