Skip to content

SpecBuilder

Defined in: extract/spec.ts:205

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

get path(): JsonPath

Defined in: extract/spec.ts:214

Current path

JsonPath

array<T>(itemMapper): ArraySpec<T>

Defined in: extract/spec.ts:269

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:228

Navigate to array index

number

SpecBuilder


boolean(): BooleanSpec

Defined in: extract/spec.ts:252

Extract as boolean

BooleanSpec


get(key): SpecBuilder

Defined in: extract/spec.ts:223

Navigate to object property

string

SpecBuilder


match(…cases): MatchSpec<Spec>

Defined in: extract/spec.ts:312

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(): NullSpec

Defined in: extract/spec.ts:257

Extract as null

NullSpec


number(): NumberSpec

Defined in: extract/spec.ts:247

Extract as number

NumberSpec


numbers(): ArraySpec<NumberSpec>

Defined in: extract/spec.ts:291

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

ArraySpec<NumberSpec>


string(): StringSpec

Defined in: extract/spec.ts:242

Extract as string

StringSpec


strings(): ArraySpec<StringSpec>

Defined in: extract/spec.ts:283

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

ArraySpec<StringSpec>


to(…keys): SpecBuilder

Defined in: extract/spec.ts:233

Navigate multiple levels at once

…(string | number)[]

SpecBuilder


static root(): SpecBuilder

Defined in: extract/spec.ts:209

Start building from root

SpecBuilder