@bjesuiter/serializr-helpers

2.2.1 • Public • Published

serializr-helpers

Provides some helper functions and serialization PropertySchemas for mobxjs/serializr - library

Content

Usage 'MomentSerializationSchema

Can be used as a factory for serializr PropSchema to serialize Moment Objects.

/**
 * A Timestamp as Moment.js object
 */
@serializable(MomentSerializationSchema())
timestamp: Moment;

With options:

/**
 * A Timestamp as Moment.js object
 */
@serializable(
MomentSerializationSchema({
    useUtc: true
})
)
timestamp: Moment;

All available options and their details could be read in ./src/lib/moment-serialization-options.ts

Usage serializr-helpers

serializeToJson()

Takes a serializr annotated object and serializes directly to json without an intermediate js-object.

deserializeFromJson()

Takes a json string and a target class object and deserializes the string into the target class instance.

serializeJson()

Alias for serializeToJson

deserializeJson()

Alias for deserializeFromJson

serializeToPojo()

Alias for native serializr serialize() function, to make the meaning less ambiguous

deserializeFromPojo()

Alias for native serializr deserialize() function, to make the meaning less ambiguous

TODOs

  • fix wallaby test running (problems with modern import syntax => current workaround: npm run test:watch)

Uses

mixu/minilog: A lighweight client & server logging lib with StreamApi backends
Docs URL: http://mixu.net/minilog/

Package Sidebar

Install

npm i @bjesuiter/serializr-helpers

Weekly Downloads

3

Version

2.2.1

License

Apache-2.0

Unpacked Size

174 kB

Total Files

153

Last publish

Collaborators

  • bjesuiter