Package: effect
Module: SchemaGetter
Builds a nested tree object from a list of bracket-path entries.
When to use
Use when you need a schema getter to parse FormData or URLSearchParams entries into structured objects.
Details
"user[address][city]" that describes nested
object/array structure."foo" → object key "foo""foo[bar]" → nested { foo: { bar: ... } }"foo[0]" → array index { foo: [value] }"foo[]" → append to array foo"" → real empty key., [ or ], so keys containing these
delimiters cannot be round-tripped without changing their structure.Example (Building a tree from bracket paths)
import { SchemaGetter } from "effect"
const tree = SchemaGetter.makeTreeRecord([
["user[name]", "Alice"],
["user[tags][]", "admin"],
["user[tags][]", "editor"]
])
// { user: { name: "Alice", tags: ["admin", "editor"] } }
See
collectBracketPathEntries for flattening trees into bracket-path entriesdecodeFormData for a higher-level FormData decoderdecodeURLSearchParams for a higher-level URLSearchParams decoderSignature
declare const makeTreeRecord: <A>(bracketPathEntries: ReadonlyArray<readonly [bracketPath: string, value: A]>) => Schema.TreeRecord<A>
Since v4.0.0