7 use parent qw(Exporter);
8 our @EXPORT = qw(encode_json decode_json to_json from_json);
12 return JSON->new(@_)->convert_blessed(1);
16 return JSON->new->convert_blessed(1)->encode(@_);
20 goto &JSON::decode_json;
24 my ($object, $options) = @_;
26 $options->{convert_blessed} = 1;
27 return JSON::to_json($object, $options);
31 goto &JSON::from_json;
43 SL::JSON - Thin wrapper around the JSON module that provides default options
49 my $escaped_text_object = SL::Presenter->get->render('some/template');
50 my $json = encode_json($escaped_text_object);
54 JSON by default does not dump or stringify blessed
55 objects. kivitendo's rendering infrastructure always returns thin
56 proxy objects as instances of L<SL::Presenter::EscapedText>. This
57 module provides the same functions that L<JSON> does but changes their
58 default regarding converting blessed arguments.
64 =item C<decode_json $json>
66 Same as L<JSON/decode_json>.
68 =item C<encode_json $object>
70 Same as L<JSON/encode_json> but sets C<convert_blessed> first.
72 =item C<from_json $object [, $options]>
74 Same as L<JSON/from_json>.
76 =item C<to_json $object [, $options ]>
78 Same as L<JSON/to_json> but sets C<convert_blessed> first.
88 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>