---
title: JSONLoader
framework: evaluations
role: symbol
role_heading: Structure
path: evaluations/jsonloader
---

# JSONLoader

A loader backed by a JSON or JSONL file.

## Declaration

```swift
struct JSONLoader<Sample> where Sample : SampleProtocol
```

## Overview

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

- [init(url:)](evaluations/jsonloader/init(url:).md)

## Relationships

### Conforms To

- [Loader](evaluations/loader.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Loaders

- [ArrayLoader](evaluations/arrayloader.md)
- [StreamLoader](evaluations/streamloader.md)
