Skip to content

Instantly share code, notes, and snippets.

@ziguzagu
Last active August 29, 2015 14:07
Show Gist options
  • Save ziguzagu/3afa745473cf28eaf831 to your computer and use it in GitHub Desktop.
Save ziguzagu/3afa745473cf28eaf831 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use Mojo::JSON qw(j);
use Storable qw(thaw nfreeze);
use Data::Dumper;
use Symbol qw(delete_package);
my $json = j('{"boolean":true,"string":"this is string"}');
warn Dumper($json);
my $bin = nfreeze($json);
## suppose in other process/program it doesn't load Mojo::JSON
delete_package('Mojo::JSON');
warn Dumper(thaw($bin));
# ✘ perl mojojson-storable.pl
# $VAR1 = {
# 'boolean' => bless( do{\(my $o = 1)}, 'Mojo::JSON::_Bool' ),
# 'string' => 'this is string'
# };
# Can't locate Mojo/JSON/_Bool.pm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment