SpecBuilder
Defined in: extract/spec.ts:406
Builder for navigating and extracting from JSON structures. Records path and produces extraction specs.
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get path():
JsonPath
Defined in: extract/spec.ts:415
Current path
Returns
Section titled “Returns”Methods
Section titled “Methods”array()
Section titled “array()”array<
T>(itemMapper):ArraySpec<T>
Defined in: extract/spec.ts:490
Mark current path as array and map over items. The mapper receives a SpecBuilder rooted at each item.
Type Parameters
Section titled “Type Parameters”T extends Spec
Parameters
Section titled “Parameters”itemMapper
Section titled “itemMapper”(item) => T
Returns
Section titled “Returns”ArraySpec<T>
at(
index):SpecBuilder
Defined in: extract/spec.ts:429
Navigate to array index
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”SpecBuilder
boolean()
Section titled “boolean()”boolean():
FormatSpec<JsonStep,"boolean">
Defined in: extract/spec.ts:463
Extract as boolean
Returns
Section titled “Returns”FormatSpec<JsonStep, "boolean">
get(
key):SpecBuilder
Defined in: extract/spec.ts:424
Navigate to object property
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”SpecBuilder
match()
Section titled “match()”Defined in: extract/spec.ts:558
Conditional extraction based on the value at current path. Each case has a predicate function and a spec to use when matched.
Parameters
Section titled “Parameters”…(MatchCase<Spec> | MatchDefault<Spec>)[]
Returns
Section titled “Returns”Example
Section titled “Example”$.get('env').match( when(eq('production'), $.get('prodConfig').string()), when(startsWith('dev'), $.get('devConfig').string()), otherwise(literal('default')))null()
Section titled “null()”null():
FormatSpec<JsonStep,"null">
Defined in: extract/spec.ts:473
Extract as null
Returns
Section titled “Returns”FormatSpec<JsonStep, "null">
number()
Section titled “number()”number():
FormatSpec<JsonStep,"number">
Defined in: extract/spec.ts:453
Extract as number
Returns
Section titled “Returns”FormatSpec<JsonStep, "number">
numbers()
Section titled “numbers()”numbers():
ArraySpec<FormatSpec<JsonStep,"number">>
Defined in: extract/spec.ts:517
Extract array of numbers. Shorthand for .array(item => item.number())
Returns
Section titled “Returns”ArraySpec<FormatSpec<JsonStep, "number">>
objects()
Section titled “objects()”objects<
T>(itemMapper):ArraySpec<ObjectSpec<T>>
Defined in: extract/spec.ts:533
Extract array of objects.
Shorthand for .array(item => object(itemMapper(item))).
Type Parameters
Section titled “Type Parameters”T extends Record<string, Spec>
Parameters
Section titled “Parameters”itemMapper
Section titled “itemMapper”(item) => T
Returns
Section titled “Returns”ArraySpec<ObjectSpec<T>>
Example
Section titled “Example”$.get('users').objects(item => ({ name: item.get('name').string(), age: item.get('age').number(),}))string()
Section titled “string()”string():
FormatSpec<JsonStep,"string">
Defined in: extract/spec.ts:443
Extract as string
Returns
Section titled “Returns”FormatSpec<JsonStep, "string">
strings()
Section titled “strings()”strings():
ArraySpec<FormatSpec<JsonStep,"string">>
Defined in: extract/spec.ts:509
Extract array of strings. Shorthand for .array(item => item.string())
Returns
Section titled “Returns”ArraySpec<FormatSpec<JsonStep, "string">>
to(…
keys):SpecBuilder
Defined in: extract/spec.ts:434
Navigate multiple levels at once
Parameters
Section titled “Parameters”…(string | number)[]
Returns
Section titled “Returns”SpecBuilder
root()
Section titled “root()”
staticroot():SpecBuilder
Defined in: extract/spec.ts:410
Start building from root
Returns
Section titled “Returns”SpecBuilder