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.
Type Parameters
Section titled “Type Parameters”T
extends AnyStruct
The schema type extending AnyStruct
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Effect Schema used to validate and decode the JSON content
config
Section titled “config”Configuration object
folder
Section titled “folder”string
Path to the directory containing JSON files
Returns
Section titled “Returns”LoaderReturn
<T
>
A Stream of validated objects matching the schema type
Throws
Section titled “Throws”When no JSON files are found, parsing fails, or validation fails
Example
Section titled “Example”const UserSchema = Schema.Struct({ id: Schema.String, name: Schema.String,});
const users = jsonFilesLoader(UserSchema, { folder: './data/users' });