s/:/ => /sog;
# Do numbers...
-# s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog;
+ #s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog;
# Change javascript stuff to perl...
s/null/ undef /sog;
$c++;
}
$output .= ']';
+ } elsif (ref($perl) and ref($perl) =~ /CODE/) {
+ $output .= perl2JSON(undef,$perl->(), $strict);
} elsif (ref($perl) and ("$perl" =~ /^([^=]+)=(\w+)/o)) {
my $type = $2;
my $name = $1;
$depth++;
for my $key (sort keys %$perl) {
$output .= ",\n" if ($c);
-
+ $output .= " "x$depth;
$output .= perl2prettyJSON($key)." : ".perl2prettyJSON($$perl{$key}, undef, 1);
$c++;
}
$depth++;
for my $part (@$perl) {
$output .= ",\n" if ($c);
-
+ $output .= " "x$depth;
$output .= perl2prettyJSON($part);
$c++;
}
$output .= "\n";
$output .= " "x$depth;
$output .= "]";
+ } elsif (ref($perl) and ref($perl) =~ /CODE/) {
+ $output .= perl2prettyJSON(undef,$perl->(), $nospace);
} elsif (ref($perl) and "$perl" =~ /^([^=]+)=(\w{4,5})\(0x/) {
my $type = $2;
my $name = $1;
} else {
$output = '"'.$perl.'"';
}
- $output .= '"'.$perl.'"';
}
return $output;