Spectral.Codec.MapSet (Spectral v0.9.2)
View SourceBuilt-in codec for MapSet.t() and MapSet.t(elem).
Encodes MapSet structs to JSON arrays and decodes JSON arrays back to MapSet.
The resulting JSON array reflects the unordered nature of sets — duplicate
entries that may appear in the decoded list are collapsed.
For MapSet.t(elem), each element is recursively encoded/decoded according to
its type. For MapSet.t(), elements are passed through as-is.
Registration
Register this codec in your application's config/config.exs or
application.ex start callback before encoding/decoding MapSet values:
Application.put_env(:spectra, :codecs, %{
{MapSet, {:type, :t, 0}} => Spectral.Codec.MapSet,
{MapSet, {:type, :t, 1}} => Spectral.Codec.MapSet
})