Skip to content

SpecBuilder

Defined in: extract/spec.ts:406

Builder for navigating and extracting from JSON structures. Records path and produces extraction specs.

get path(): JsonPath

Defined in: extract/spec.ts:415

Current path

JsonPath

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.

T extends Spec

(item) => T

ArraySpec<T>


at(index): SpecBuilder

Defined in: extract/spec.ts:429

Navigate to array index

number

SpecBuilder


boolean(): FormatSpec<JsonStep, "boolean">

Defined in: extract/spec.ts:463

Extract as boolean

FormatSpec<JsonStep, "boolean">


get(key): SpecBuilder

Defined in: extract/spec.ts:424

Navigate to object property

string

SpecBuilder


match(…cases): MatchSpec<Spec>

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.

…(MatchCase<Spec> | MatchDefault<Spec>)[]

MatchSpec<Spec>

$.get('env').match(
when(eq('production'), $.get('prodConfig').string()),
when(startsWith('dev'), $.get('devConfig').string()),
otherwise(literal('default'))
)

null(): FormatSpec<JsonStep, "null">

Defined in: extract/spec.ts:473

Extract as null

FormatSpec<JsonStep, "null">


number(): FormatSpec<JsonStep, "number">

Defined in: extract/spec.ts:453

Extract as number

FormatSpec<JsonStep, "number">


numbers(): ArraySpec<FormatSpec<JsonStep, "number">>

Defined in: extract/spec.ts:517

Extract array of numbers. Shorthand for .array(item => item.number())

ArraySpec<FormatSpec<JsonStep, "number">>


objects<T>(itemMapper): ArraySpec<ObjectSpec<T>>

Defined in: extract/spec.ts:533

Extract array of objects. Shorthand for .array(item => object(itemMapper(item))).

T extends Record<string, Spec>

(item) => T

ArraySpec<ObjectSpec<T>>

$.get('users').objects(item => ({
name: item.get('name').string(),
age: item.get('age').number(),
}))

string(): FormatSpec<JsonStep, "string">

Defined in: extract/spec.ts:443

Extract as string

FormatSpec<JsonStep, "string">


strings(): ArraySpec<FormatSpec<JsonStep, "string">>

Defined in: extract/spec.ts:509

Extract array of strings. Shorthand for .array(item => item.string())

ArraySpec<FormatSpec<JsonStep, "string">>


to(…keys): SpecBuilder

Defined in: extract/spec.ts:434

Navigate multiple levels at once

…(string | number)[]

SpecBuilder


static root(): SpecBuilder

Defined in: extract/spec.ts:410

Start building from root

SpecBuilder