line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###############################################################################
|
2
|
|
|
|
|
|
|
#jsonify.pm
|
3
|
|
|
|
|
|
|
#Last Change: 2009-01-21
|
4
|
|
|
|
|
|
|
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
|
5
|
|
|
|
|
|
|
#Version 0.1
|
6
|
|
|
|
|
|
|
####################
|
7
|
|
|
|
|
|
|
#This file is an addon to the Dotiac::DTL project.
|
8
|
|
|
|
|
|
|
#http://search.cpan.org/perldoc?Dotiac::DTL
|
9
|
|
|
|
|
|
|
#
|
10
|
|
|
|
|
|
|
#jsonify.pm is published under the terms of the MIT license, which basically
|
11
|
|
|
|
|
|
|
#means "Do with it whatever you want". For more information, see the
|
12
|
|
|
|
|
|
|
#license.txt file that should be enclosed with this distribution\. A copy of
|
13
|
|
|
|
|
|
|
#the license is (at the time of writing) also available at
|
14
|
|
|
|
|
|
|
#http://www.opensource.org/licenses/mit-license.php .
|
15
|
|
|
|
|
|
|
###############################################################################
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Dotiac::DTL::Addon::jsonify;
|
19
|
1
|
|
|
1
|
|
140629
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
20
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
296
|
|
21
|
|
|
|
|
|
|
require JSON;
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#If it is not already loaded.
|
24
|
|
|
|
|
|
|
require Dotiac::DTL::Filter;
|
25
|
|
|
|
|
|
|
require Dotiac::DTL::Value;
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION=0.1;
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $json=JSON->new();
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#Global options, allow as much as possible.
|
34
|
|
|
|
|
|
|
$json->allow_nonref(1);
|
35
|
|
|
|
|
|
|
$json->allow_blessed(1);
|
36
|
|
|
|
|
|
|
$json->allow_unknown(1);
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $oldjsonify;
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub import {
|
42
|
6
|
|
|
6
|
|
5729
|
$oldjsonify = *{Dotiac::DTL::Filter::jsonify};
|
43
|
6
|
|
|
|
|
21
|
*{Dotiac::DTL::Filter::jsonify}=\&jsonify;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
sub unimport {
|
47
|
6
|
|
|
6
|
|
1360
|
*{Dotiac::DTL::Filter::jsonify} = $oldjsonify;
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub jsonify {
|
51
|
4
|
|
|
4
|
0
|
266
|
my $value=shift;
|
52
|
4
|
|
|
|
|
19
|
$Dotiac::DTL::Addon::jsonify::json->pretty(0);
|
53
|
4
|
|
|
|
|
13
|
$Dotiac::DTL::Addon::jsonify::json->ascii(1);
|
54
|
4
|
|
|
|
|
17
|
$value->safe(1);
|
55
|
4
|
|
|
|
|
42
|
return $value->set($json->encode($value->content));
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1;
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__
|