Decree.Serialization.JsonSerializer (decree v0.1.0)

Copy Markdown View Source

A serializer that uses the JSON format and Jason library.

Summary

Functions

Deserialize given JSON binary data to the expected type.

Whether the configured Decree.EventStore.TypeProvider can build the type, as deserialize/2 asks it to. Used by the event store as its serializer's Decree.Store.Serializer.known_type?/1.

Serialize given term to JSON binary data.

Functions

deserialize(binary, config \\ [])

Deserialize given JSON binary data to the expected type.

known_type?(type)

Whether the configured Decree.EventStore.TypeProvider can build the type, as deserialize/2 asks it to. Used by the event store as its serializer's Decree.Store.Serializer.known_type?/1.

Answers false, so the event holds, when the provider cannot map the type name: when it raises ArgumentError (the default provider, for a name that is no existing atom), UndefinedFunctionError (a name that is no struct module) or a FunctionClauseError from the provider's own to_struct/1 (a custom provider with clauses only for the names it knows, meeting a newer one). Any other exception the provider raises, including a FunctionClauseError from a function it calls, is a crash, not an unknown type, and is raised.

serialize(term)

Serialize given term to JSON binary data.