Skip to main content
Module

x/ts_serialize/mod.ts

A zero dependency library for serializing data
Latest
import * as tsSerialize from "https://deno.land/x/ts_serialize@v2.0.3/mod.ts";

Functions

Function to build a fromJSONStrategy or toJSONStrategy. Converts value from functions provided as parameters

allows authors to pass a regex to parse as a date

convert { [_: string]: Serializable } to { [_: string]: Serializable.tsSerialize() }

serialize data using tsSerialize on a subclass Serializable type

get new strategy type arguments

Test a string for a ISO 8601 Date

Uses either the polymorphic resolver or the polymorphic switch resolver to determine the appropriate class, then deserialize the input using Serializable#fromJSON, returning the result

@PolymorphicResolver method decorator

@PolymorphicSwitch property decorator.

Property wrapper that adds SerializeProperty options to the class map

revive data from {k: v} using fromJSON on a subclass type v

revive data using fromJSON on a subclass type

Interfaces

deep copy this, jsonObject is a POJO of the class that overrides the cloned object, jsonObject keys do not need keyTransforms, and values are raw JS Objects

reutrns a new javascript object with transformations

returns the javascript object as a JSONObject with transformations

returns the object as a string with transformations

called against every property key transforming the key with the provided function

Type Aliases

Functions used when hydrating data. While we do know that the incoming param is a JSONValue, this forces authors using the library to recast the known type before using it. By using any they can cast it in the function signature

Function type to ensure that initializers take no arguments and return a valid serializable

A JSONObject where each string property value is a JSONValue.

A JSONValue

Functions used when dehydrating data