1Dancer2::Core::Role::SeUrsiearliCzoenrt(r3i)buted Perl DDoacnucmeern2t:a:tCioorne::Role::Serializer(3)
2
3
4
6 Dancer2::Core::Role::Serializer - Role for Serializer engines
7
9 version 0.207000
10
12 Any class that consumes this role will be able to be used as a
13 serializer under Dancer2.
14
15 In order to implement this role, the consumer must implement the
16 methods "serialize" and "deserialize", and should define the
17 "content_type" attribute value.
18
20 content_type
21 The content type of the object after being serialized. For example, a
22 JSON serializer would have a application/json content type defined.
23
25 serialize($content, [\%options])
26 The serialize method need to be implemented by the consumer. It
27 receives the serializer class object and a reference to the object to
28 be serialized. Should return the object after being serialized, in the
29 content type defined by the "content_type" attribute.
30
31 A third optional argument is a hash reference of options to the
32 serializer.
33
34 The serialize method must return bytes and therefore has to handle any
35 encoding.
36
37 deserialize($content, [\%options])
38 The inverse method of "serialize". Receives the serializer class object
39 and a string that should be deserialized. The method should return a
40 reference to the deserialized Perl data structure.
41
42 A third optional argument is a hash reference of options to the
43 serializer.
44
45 The deserialize method receives encoded bytes and must therefore handle
46 any decoding required.
47
49 The serializer configuration variable tells Dancer2 which engine to
50 use.
51
52 You can change it either in your config.yml file:
53
54 #Set JSON engine
55 serializer: "JSON"
56
57 # Prettify JSON output
58 engines:
59 serializer:
60 JSON:
61 pretty: 1
62
63 To know which engines are availables please see "Serializers" in
64 Dancer2::Manual
65
67 Dancer Core Developers
68
70 This software is copyright (c) 2018 by Alexis Sukrieh.
71
72 This is free software; you can redistribute it and/or modify it under
73 the same terms as the Perl 5 programming language system itself.
74
75
76
77perl v5.28.0 2018-11-14Dancer2::Core::Role::Serializer(3)