JSON Value Types
Types representing valid JSON values that can be encoded/decoded.JsonPrimitive
Represents JSON primitive values.string- Text valuesnumber- Numeric values (integers and floats)boolean-trueorfalsenull- Null value
Example
Example
JsonObject
Represents a JSON object with string keys and JsonValue values.- Keys are always strings
- Values can be any
JsonValue(including nested objects and arrays) - Properties can be optional or undefined
Example
Example
JsonArray
Represents a JSON array of JsonValue elements.Example
Example
JsonValue
Union type representing any valid JSON value.Example
Example
Delimiter Types
Types for controlling how values are separated in arrays.DelimiterKey
String literal type for delimiter names.'comma'- Comma-separated values (default)'tab'- Tab-separated values'pipe'- Pipe-separated values
Delimiter
The actual delimiter character type.','- Comma (comma key)'\t'- Tab character (tab key)'|'- Pipe (pipe key)
Example
Example
Encoder Types
Types related to the encoding process.EncodeReplacer
Function type for transforming or filtering values during encoding.key- The property key or array index (as string). Empty string ('') for root value.value- The normalizedJsonValueat this location.path- Array representing the path from root to this value.
- The replacement value (will be normalized again), or
undefinedto omit. - For root value, returning
undefinedmeans “no change” (don’t omit root).
Example
Example
EncodeOptions
Configuration interface for encoding operations.ResolvedEncodeOptions
Internal type representing fully resolved encoding options.replacer which remains optional. This type is used internally and typically not needed in application code.
Decoder Types
Types related to the decoding process.DecodeOptions
Configuration interface for decoding operations.DecodeStreamOptions
Specialized options interface for streaming decode that explicitly omitsexpandPaths.
Example
Example
ResolvedDecodeOptions
Internal type representing fully resolved decoding options.Streaming Types
Types for streaming decode operations.JsonStreamEvent
Union type representing events emitted by streaming decoders.{ type: 'startObject' }
Signals the beginning of an object. All following
key events until the matching endObject are properties of this object.{ type: 'endObject' }
Signals the end of an object. Matches the most recent unmatched
startObject.{ type: 'startArray', length: number }
Signals the beginning of an array. The
length property indicates the declared array length from the TOON header.{ type: 'endArray' }
Signals the end of an array. Matches the most recent unmatched
startArray.{ type: 'key', key: string, wasQuoted?: boolean }
Signals an object property key. The next event (which may be another event like
startObject) is the value for this key.The optional wasQuoted field is true if the key was quoted in the TOON source.{ type: 'primitive', value: JsonPrimitive }
Signals a primitive value (string, number, boolean, or null). The
value field contains the parsed primitive.Event Stream Example
Event Stream Example
Internal Types
These types are used internally by the library and are typically not needed in application code.ArrayHeaderInfo
Information parsed from a TOON array header line.string | undefined
The optional key name before the array header (e.g.,
users in users[3]:).number
The declared length of the array (e.g.,
3 in users[3]:).Delimiter
The delimiter used for array values.
string[] | undefined
For tabular arrays, the field names (e.g.,
['id', 'name', 'email'] in users[2]{id,name,email}:).ParsedLine
Represents a parsed line from TOON input during decoding.string
The original line text including indentation.
Depth
The computed nesting depth based on indentation.
number
The number of spaces of indentation.
string
The line content with indentation removed.
number
The 1-based line number in the input.
BlankLineInfo
Information about a blank line encountered during parsing.Depth
Type alias for representing nesting depth.Constants
DELIMITERS
Object containing all available delimiter values.Example
Example
DEFAULT_DELIMITER
The default delimiter used when none is specified.Type Imports
All types are exported from the main package entry point:See Also
- EncodeOptions - Detailed encoding options documentation
- DecodeOptions - Detailed decoding options documentation
- API Reference - Function API documentation
