NAME
Dancer2::Plugin::JsonApi::Schema
VERSION
version 0.0.1
DESCRIPTION
Defines a type of object to serialize/deserialize from/to the JSON:API format.
ATTRIBUTES
registry
Dancer2::Plugin::JsonApi::Registry to use to find the definition of other object types.
before_serialize
Accepts a function, which will be called on the original $data
to serialize to groom it.
before_serialize => sub($data,$xtra) {
# lowercase all keys
return +{ pairmap { lc($a) => $b } %$data }
}
type
The JSON:API object type. Read-only, required.
id
Key to use as a reference to the object. Can be a string, or a function that will be passed the original data object. Read-only, defaults to the string id
.
links
Links to include as part of the object.
top_level_links
Links to include to the serialized top level, if the top level object is of the type defined by this class.
top_level_meta
Meta information to include to the serialized top level, if the top level object is of the type defined by this class.
relationships
Relationships for the object type.
allowed_attributes
List of attributes that can be serialized/deserialized.
METHODS
top_level_serialize($data,$extra_data = {})
Serializes $data
as a top-level JSON:API object.
serialize_data($data,$extra_data)
Serializes the inner $data
.
AUTHOR
Yanick Champoux <yanick@babyl.ca>
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.