Contents

JSONLoader

A loader backed by a JSON or JSONL file.

Declaration

struct JSONLoader<Sample> where Sample : SampleProtocol

Overview

The format is detected automatically from the file contents:

  • If the first non-whitespace character is [, the file is treated as a JSON array ([{...}, {...}]) and decoded in one pass.

  • Otherwise, the file is treated as JSONL (JSON Lines), where each non-empty line is decoded as an individual sample.

Malformed entries are logged via OSLog and skipped. A failure to open the file propagates as a thrown error.

Topics

Initializers

See Also

Loaders