Group
Extension

Matches 1

JSON-Conditional ( L/LN/LNATION/JSON-Conditional-1.02.tar.gz, LNATION, 2025; MetaCPAN )
JSON-Conditional/lib/JSON/Conditional.pm ( view source; MetaCPAN )
package JSON::Conditional;
use 5.006; use strict; use warnings; our $VERSION = '1.02';
use JSON; use base 'Struct::Conditional';

our $JSON;

BEGIN {
	$JSON = JSON->new->pretty(1)->allow_blessed->conv
ert_blessed;
}

sub encode {
	if ($_[2]) {
		$_[0]->encode_file($_[1], $_[2]);
	}
	$JSON->encode($_[1]);
}

sub encode_file {
	open my $file, '>', $_[2] or die "cannot open file $!";
	print $file $_[0
le;
}

sub decode {
	if ( $_[1] !~ m/\n/ && -f $_[1]) {
		return $_[0]->decode_file($_[1]);
	} 
	$JSON->decode($_[1]);
}

sub decode_file {
	open my $file, '<', $_[1] or die "cannot open file $!";
	my

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.