source: main/trunk/greenstone2/perllib/cpan/JSON/PP58.pm@ 24921

Last change on this file since 24921 was 24921, checked in by davidb, 12 years ago

Some of our perl CGI scripts use JSON, while included in the ActivePerl distribution, it does not appear to be a standard Perl module

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1package JSON::PP58;
2
3use 5.008;
4use strict;
5
6my @properties;
7
8$JSON::PP58::VERSION = '1.03';
9
10
11BEGIN {
12
13 unless ( defined &utf8::is_utf8 ) {
14 require Encode;
15 *utf8::is_utf8 = *Encode::is_utf8;
16 }
17
18 *JSON::PP::JSON_PP_encode_ascii = \&JSON::PP::_encode_ascii;
19 *JSON::PP::JSON_PP_encode_latin1 = \&JSON::PP::_encode_latin1;
20 *JSON::PP::JSON_PP_decode_surrogates = \&JSON::PP::_decode_surrogates;
21 *JSON::PP::JSON_PP_decode_unicode = \&JSON::PP::_decode_unicode;
22
23 if ($] >= 5.008 and $] < 5.008003) { # join() in 5.8.0 - 5.8.2 is broken.
24 package JSON::PP;
25 require subs;
26 subs->import('join');
27 eval q|
28 sub join {
29 return '' if (@_ < 2);
30 my $j = shift;
31 my $str = shift;
32 for (@_) { $str .= $j . $_; }
33 return $str;
34 }
35 |;
36 }
37
38}
39
40
41sub JSON::PP::incr_parse {
42 local $Carp::CarpLevel = 1;
43 ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_parse( @_ );
44}
45
46
47sub JSON::PP::incr_text : lvalue {
48 $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new;
49
50 if ( $_[0]->{_incr_parser}->{incr_parsing} ) {
51 Carp::croak("incr_text can not be called when the incremental parser already started parsing");
52 }
53 $_[0]->{_incr_parser}->{incr_text};
54}
55
56
57sub JSON::PP::incr_skip {
58 ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_skip;
59}
60
61
62sub JSON::PP::incr_reset {
63 ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_reset;
64}
65
66
671;
68__END__
69
70=pod
71
72=head1 NAME
73
74JSON::PP58 - Helper module in using JSON::PP in Perl 5.8 and lator
75
76=head1 DESCRIPTION
77
78JSON::PP calls internally.
79
80=head1 AUTHOR
81
82Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
83
84
85=head1 COPYRIGHT AND LICENSE
86
87Copyright 2008-2009 by Makamaka Hannyaharamitu
88
89This library is free software; you can redistribute it and/or modify
90it under the same terms as Perl itself.
91
92=cut
93
Note: See TracBrowser for help on using the repository browser.