Skip to content

jsonFilesLoader

jsonFilesLoader<T>(schema, config): LoaderReturn<T>

Defined in: packages/core/src/loaders.ts:67

Loads and parses JSON files from a directory, validating each file against a schema.

T extends AnyStruct

The schema type extending AnyStruct

T

Effect Schema used to validate and decode the JSON content

Configuration object

string

Path to the directory containing JSON files

LoaderReturn<T>

A Stream of validated objects matching the schema type

When no JSON files are found, parsing fails, or validation fails

const UserSchema = Schema.Struct({
id: Schema.String,
name: Schema.String,
});
const users = jsonFilesLoader(UserSchema, { folder: './data/users' });