App-PlatformInfo
view release on metacpan or search on metacpan
script/platform-info view on Meta::CPAN
### JSON/PP.pm ###
#package JSON::PP;
#
#
#use 5.005;
#use strict;
#
#use Exporter ();
#BEGIN { @JSON::PP::ISA = ('Exporter') }
#
#use overload ();
#use JSON::PP::Boolean;
#
#use Carp ();
#
#$JSON::PP::VERSION = '4.02';
#
#@JSON::PP::EXPORT = qw(encode_json decode_json from_json to_json);
#
#
#use constant P_ASCII => 0;
#use constant P_LATIN1 => 1;
#use constant P_UTF8 => 2;
#use constant P_INDENT => 3;
#use constant P_CANONICAL => 4;
#use constant P_SPACE_BEFORE => 5;
#use constant P_SPACE_AFTER => 6;
#use constant P_ALLOW_NONREF => 7;
#use constant P_SHRINK => 8;
#use constant P_ALLOW_BLESSED => 9;
#use constant P_CONVERT_BLESSED => 10;
#use constant P_RELAXED => 11;
#
#use constant P_LOOSE => 12;
#use constant P_ALLOW_BIGNUM => 13;
#use constant P_ALLOW_BAREKEY => 14;
#use constant P_ALLOW_SINGLEQUOTE => 15;
#use constant P_ESCAPE_SLASH => 16;
#use constant P_AS_NONBLESSED => 17;
#
#use constant P_ALLOW_UNKNOWN => 18;
#use constant P_ALLOW_TAGS => 19;
#
#use constant OLD_PERL => $] < 5.008 ? 1 : 0;
#use constant USE_B => $ENV{PERL_JSON_PP_USE_B} || 0;
#
#BEGIN {
# if (USE_B) {
# require B;
# }
#}
#
#BEGIN {
# my @xs_compati_bit_properties = qw(
# latin1 ascii utf8 indent canonical space_before space_after allow_nonref shrink
# allow_blessed convert_blessed relaxed allow_unknown
# allow_tags
# );
# my @pp_bit_properties = qw(
# allow_singlequote allow_bignum loose
# allow_barekey escape_slash as_nonblessed
# );
#
# if ( OLD_PERL ) {
# my $helper = $] >= 5.006 ? 'JSON::PP::Compat5006' : 'JSON::PP::Compat5005';
# eval qq| require $helper |;
# if ($@) { Carp::croak $@; }
# }
#
# for my $name (@xs_compati_bit_properties, @pp_bit_properties) {
# my $property_id = 'P_' . uc($name);
#
# eval qq/
# sub $name {
# my \$enable = defined \$_[1] ? \$_[1] : 1;
#
# if (\$enable) {
# \$_[0]->{PROPS}->[$property_id] = 1;
# }
# else {
# \$_[0]->{PROPS}->[$property_id] = 0;
# }
#
# \$_[0];
# }
#
# sub get_$name {
# \$_[0]->{PROPS}->[$property_id] ? 1 : '';
# }
# /;
# }
#
#}
#
#
#
#
#my $JSON;
#
#sub encode_json ($) {
# ($JSON ||= __PACKAGE__->new->utf8)->encode(@_);
#}
#
#
#sub decode_json {
# ($JSON ||= __PACKAGE__->new->utf8)->decode(@_);
#}
#
#
#sub to_json($) {
# Carp::croak ("JSON::PP::to_json has been renamed to encode_json.");
#}
#
#
#sub from_json($) {
# Carp::croak ("JSON::PP::from_json has been renamed to decode_json.");
#}
#
#
#
#sub new {
script/platform-info view on Meta::CPAN
# }
# $_[0]->{F_HOOK} = ($_[0]->{cb_object} or $_[0]->{cb_sk_object}) ? 1 : 0;
# $_[0];
#}
#
#sub filter_json_single_key_object {
# if (@_ == 1 or @_ > 3) {
# Carp::croak("Usage: JSON::PP::filter_json_single_key_object(self, key, callback = undef)");
# }
# if (defined $_[2] and ref $_[2] eq 'CODE') {
# $_[0]->{cb_sk_object}->{$_[1]} = $_[2];
# } else {
# delete $_[0]->{cb_sk_object}->{$_[1]};
# delete $_[0]->{cb_sk_object} unless %{$_[0]->{cb_sk_object} || {}};
# }
# $_[0]->{F_HOOK} = ($_[0]->{cb_object} or $_[0]->{cb_sk_object}) ? 1 : 0;
# $_[0];
#}
#
#sub indent_length {
# if (!defined $_[1] or $_[1] > 15 or $_[1] < 0) {
# Carp::carp "The acceptable range of indent_length() is 0 to 15.";
# }
# else {
# $_[0]->{indent_length} = $_[1];
# }
# $_[0];
#}
#
#sub get_indent_length {
# $_[0]->{indent_length};
#}
#
#sub sort_by {
# $_[0]->{sort_by} = defined $_[1] ? $_[1] : 1;
# $_[0];
#}
#
#sub allow_bigint {
# Carp::carp("allow_bigint() is obsoleted. use allow_bignum() instead.");
# $_[0]->allow_bignum;
#}
#
#
#
#
#{
#
# my $max_depth;
# my $indent;
# my $ascii;
# my $latin1;
# my $utf8;
# my $space_before;
# my $space_after;
# my $canonical;
# my $allow_blessed;
# my $convert_blessed;
#
# my $indent_length;
# my $escape_slash;
# my $bignum;
# my $as_nonblessed;
# my $allow_tags;
#
# my $depth;
# my $indent_count;
# my $keysort;
#
#
# sub PP_encode_json {
# my $self = shift;
# my $obj = shift;
#
# $indent_count = 0;
# $depth = 0;
#
# my $props = $self->{PROPS};
#
# ($ascii, $latin1, $utf8, $indent, $canonical, $space_before, $space_after, $allow_blessed,
# $convert_blessed, $escape_slash, $bignum, $as_nonblessed, $allow_tags)
# = @{$props}[P_ASCII .. P_SPACE_AFTER, P_ALLOW_BLESSED, P_CONVERT_BLESSED,
# P_ESCAPE_SLASH, P_ALLOW_BIGNUM, P_AS_NONBLESSED, P_ALLOW_TAGS];
#
# ($max_depth, $indent_length) = @{$self}{qw/max_depth indent_length/};
#
# $keysort = $canonical ? sub { $a cmp $b } : undef;
#
# if ($self->{sort_by}) {
# $keysort = ref($self->{sort_by}) eq 'CODE' ? $self->{sort_by}
# : $self->{sort_by} =~ /\D+/ ? $self->{sort_by}
# : sub { $a cmp $b };
# }
#
# encode_error("hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this)")
# if(!ref $obj and !$props->[ P_ALLOW_NONREF ]);
#
# my $str = $self->object_to_json($obj);
#
# $str .= "\n" if ( $indent );
#
# unless ($ascii or $latin1 or $utf8) {
# utf8::upgrade($str);
# }
#
# if ($props->[ P_SHRINK ]) {
# utf8::downgrade($str, 1);
# }
#
# return $str;
# }
#
#
# sub object_to_json {
# my ($self, $obj) = @_;
# my $type = ref($obj);
#
# if($type eq 'HASH'){
# return $self->hash_to_json($obj);
# }
# elsif($type eq 'ARRAY'){
# return $self->array_to_json($obj);
# }
# elsif ($type) {
# if (blessed($obj)) {
#
# return $self->value_to_json($obj) if ( $obj->isa('JSON::PP::Boolean') );
#
# if ( $allow_tags and $obj->can('FREEZE') ) {
# my $obj_class = ref $obj || $obj;
# $obj = bless $obj, $obj_class;
# my @results = $obj->FREEZE('JSON');
# if ( @results and ref $results[0] ) {
# if ( refaddr( $obj ) eq refaddr( $results[0] ) ) {
# encode_error( sprintf(
# "%s::FREEZE method returned same object as was passed instead of a new one",
# ref $obj
# ) );
# }
# }
# return '("'.$obj_class.'")['.join(',', @results).']';
script/platform-info view on Meta::CPAN
# sub value_to_json {
# my ($self, $value) = @_;
#
# return 'null' if(!defined $value);
#
# my $type = ref($value);
#
# if (!$type) {
# if (_looks_like_number($value)) {
# return $value;
# }
# return $self->string_to_json($value);
# }
# elsif( blessed($value) and $value->isa('JSON::PP::Boolean') ){
# return $$value == 1 ? 'true' : 'false';
# }
# else {
# if ((overload::StrVal($value) =~ /=(\w+)/)[0]) {
# return $self->value_to_json("$value");
# }
#
# if ($type eq 'SCALAR' and defined $$value) {
# return $$value eq '1' ? 'true'
# : $$value eq '0' ? 'false'
# : $self->{PROPS}->[ P_ALLOW_UNKNOWN ] ? 'null'
# : encode_error("cannot encode reference to scalar");
# }
#
# if ( $self->{PROPS}->[ P_ALLOW_UNKNOWN ] ) {
# return 'null';
# }
# else {
# if ( $type eq 'SCALAR' or $type eq 'REF' ) {
# encode_error("cannot encode reference to scalar");
# }
# else {
# encode_error("encountered $value, but JSON can only represent references to arrays or hashes");
# }
# }
#
# }
# }
#
#
# my %esc = (
# "\n" => '\n',
# "\r" => '\r',
# "\t" => '\t',
# "\f" => '\f',
# "\b" => '\b',
# "\"" => '\"',
# "\\" => '\\\\',
# "\'" => '\\\'',
# );
#
#
# sub string_to_json {
# my ($self, $arg) = @_;
#
# $arg =~ s/([\x22\x5c\n\r\t\f\b])/$esc{$1}/g;
# $arg =~ s/\//\\\//g if ($escape_slash);
# $arg =~ s/([\x00-\x08\x0b\x0e-\x1f])/'\\u00' . unpack('H2', $1)/eg;
#
# if ($ascii) {
# $arg = JSON_PP_encode_ascii($arg);
# }
#
# if ($latin1) {
# $arg = JSON_PP_encode_latin1($arg);
# }
#
# if ($utf8) {
# utf8::encode($arg);
# }
#
# return '"' . $arg . '"';
# }
#
#
# sub blessed_to_json {
# my $reftype = reftype($_[1]) || '';
# if ($reftype eq 'HASH') {
# return $_[0]->hash_to_json($_[1]);
# }
# elsif ($reftype eq 'ARRAY') {
# return $_[0]->array_to_json($_[1]);
# }
# else {
# return 'null';
# }
# }
#
#
# sub encode_error {
# my $error = shift;
# Carp::croak "$error";
# }
#
#
# sub _sort {
# defined $keysort ? (sort $keysort (keys %{$_[0]})) : keys %{$_[0]};
# }
#
#
# sub _up_indent {
# my $self = shift;
# my $space = ' ' x $indent_length;
#
# my ($pre,$post) = ('','');
#
# $post = "\n" . $space x $indent_count;
#
# $indent_count++;
#
# $pre = "\n" . $space x $indent_count;
#
# return ($pre,$post);
# }
#
#
# sub _down_indent { $indent_count--; }
script/platform-info view on Meta::CPAN
# indent_count => $indent_count,
# };
# }
#
#}
#
#
#sub _encode_ascii {
# join('',
# map {
# $_ <= 127 ?
# chr($_) :
# $_ <= 65535 ?
# sprintf('\u%04x', $_) : sprintf('\u%x\u%x', _encode_surrogates($_));
# } unpack('U*', $_[0])
# );
#}
#
#
#sub _encode_latin1 {
# join('',
# map {
# $_ <= 255 ?
# chr($_) :
# $_ <= 65535 ?
# sprintf('\u%04x', $_) : sprintf('\u%x\u%x', _encode_surrogates($_));
# } unpack('U*', $_[0])
# );
#}
#
#
#sub _encode_surrogates {
# my $uni = $_[0] - 0x10000;
# return ($uni / 0x400 + 0xD800, $uni % 0x400 + 0xDC00);
#}
#
#
#sub _is_bignum {
# $_[0]->isa('Math::BigInt') or $_[0]->isa('Math::BigFloat');
#}
#
#
#
#
#my $max_intsize;
#
#BEGIN {
# my $checkint = 1111;
# for my $d (5..64) {
# $checkint .= 1;
# my $int = eval qq| $checkint |;
# if ($int =~ /[eE]/) {
# $max_intsize = $d - 1;
# last;
# }
# }
#}
#
#{
#
# my %escapes = (
# b => "\x8",
# t => "\x9",
# n => "\xA",
# f => "\xC",
# r => "\xD",
# '\\' => '\\',
# '"' => '"',
# '/' => '/',
# );
#
# my $text;
# my $at;
# my $ch;
# my $len;
# my $depth;
# my $encoding;
# my $is_valid_utf8;
# my $utf8_len;
# my $utf8;
# my $max_depth;
# my $max_size;
# my $relaxed;
# my $cb_object;
# my $cb_sk_object;
#
# my $F_HOOK;
#
# my $allow_bignum;
# my $singlequote;
# my $loose;
# my $allow_barekey;
# my $allow_tags;
#
# my $alt_true;
# my $alt_false;
#
# sub _detect_utf_encoding {
# my $text = shift;
# my @octets = unpack('C4', $text);
# return 'unknown' unless defined $octets[3];
# return ( $octets[0] and $octets[1]) ? 'UTF-8'
# : (!$octets[0] and $octets[1]) ? 'UTF-16BE'
# : (!$octets[0] and !$octets[1]) ? 'UTF-32BE'
# : ( $octets[2] ) ? 'UTF-16LE'
# : (!$octets[2] ) ? 'UTF-32LE'
# : 'unknown';
# }
#
# sub PP_decode_json {
# my ($self, $want_offset);
#
# ($self, $text, $want_offset) = @_;
#
# ($at, $ch, $depth) = (0, '', 0);
#
# if ( !defined $text or ref $text ) {
# decode_error("malformed JSON string, neither array, object, number, string or atom");
# }
#
# my $props = $self->{PROPS};
script/platform-info view on Meta::CPAN
# . ' use allow_nonref to allow this)', 1);
# }
#
# Carp::croak('something wrong.') if $len < $at;
#
# my $consumed = defined $ch ? $at - 1 : $at;
#
# white();
#
# return ( $result, $consumed ) if $want_offset;
#
# decode_error("garbage after JSON object") if defined $ch;
#
# $result;
# }
#
#
# sub next_chr {
# return $ch = undef if($at >= $len);
# $ch = substr($text, $at++, 1);
# }
#
#
# sub value {
# white();
# return if(!defined $ch);
# return object() if($ch eq '{');
# return array() if($ch eq '[');
# return tag() if($ch eq '(');
# return string() if($ch eq '"' or ($singlequote and $ch eq "'"));
# return number() if($ch =~ /[0-9]/ or $ch eq '-');
# return word();
# }
#
# sub string {
# my $utf16;
# my $is_utf8;
#
# ($is_valid_utf8, $utf8_len) = ('', 0);
#
# my $s = '';
#
# if($ch eq '"' or ($singlequote and $ch eq "'")){
# my $boundChar = $ch;
#
# OUTER: while( defined(next_chr()) ){
#
# if($ch eq $boundChar){
# next_chr();
#
# if ($utf16) {
# decode_error("missing low surrogate character in surrogate pair");
# }
#
# utf8::decode($s) if($is_utf8);
#
# return $s;
# }
# elsif($ch eq '\\'){
# next_chr();
# if(exists $escapes{$ch}){
# $s .= $escapes{$ch};
# }
# elsif($ch eq 'u'){
# my $u = '';
#
# for(1..4){
# $ch = next_chr();
# last OUTER if($ch !~ /[0-9a-fA-F]/);
# $u .= $ch;
# }
#
# if ($u =~ /^[dD][89abAB][0-9a-fA-F]{2}/) {
# $utf16 = $u;
# }
# elsif ($u =~ /^[dD][c-fC-F][0-9a-fA-F]{2}/) {
# unless (defined $utf16) {
# decode_error("missing high surrogate character in surrogate pair");
# }
# $is_utf8 = 1;
# $s .= JSON_PP_decode_surrogates($utf16, $u) || next;
# $utf16 = undef;
# }
# else {
# if (defined $utf16) {
# decode_error("surrogate pair expected");
# }
#
# if ( ( my $hex = hex( $u ) ) > 127 ) {
# $is_utf8 = 1;
# $s .= JSON_PP_decode_unicode($u) || next;
# }
# else {
# $s .= chr $hex;
# }
# }
#
# }
# else{
# unless ($loose) {
# $at -= 2;
# decode_error('illegal backslash escape sequence in string');
# }
# $s .= $ch;
# }
# }
# else{
#
# if ( ord $ch > 127 ) {
# unless( $ch = is_valid_utf8($ch) ) {
# $at -= 1;
# decode_error("malformed UTF-8 character in JSON string");
# }
# else {
# $at += $utf8_len - 1;
# }
#
# $is_utf8 = 1;
# }
#
# if (!$loose) {
# if ($ch =~ /[\x00-\x1f\x22\x5c]/) {
# if (!$relaxed or $ch ne "\t") {
# $at--;
# decode_error('invalid character encountered while parsing JSON string');
# }
# }
# }
#
# $s .= $ch;
# }
# }
# }
#
# decode_error("unexpected end of string while parsing JSON string");
# }
#
#
# sub white {
# while( defined $ch ){
# if($ch eq '' or $ch =~ /\A[ \t\r\n]\z/){
# next_chr();
# }
# elsif($relaxed and $ch eq '/'){
# next_chr();
# if(defined $ch and $ch eq '/'){
# 1 while(defined(next_chr()) and $ch ne "\n" and $ch ne "\r");
# }
# elsif(defined $ch and $ch eq '*'){
# next_chr();
# while(1){
# if(defined $ch){
# if($ch eq '*'){
# if(defined(next_chr()) and $ch eq '/'){
# next_chr();
# last;
# }
# }
# else{
# next_chr();
# }
# }
( run in 1.290 second using v1.01-cache-2.11-cpan-39bf76dae61 )