Skip to content

Commit

Permalink
JSON::PP allows single quote JSON format.
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Mar 20, 2010
1 parent 9500d0e commit 19924d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions MANIFEST
Expand Up @@ -5,15 +5,18 @@ bin/vim_record
bin/vimana
bundle.pl
Changes
cleanup.sh
cpan-setup.sh
dist_par_binary.sh
http.pl
inc/Module/AutoInstall.pm
inc/Module/Install.pm
inc/Module/Install/AutoInstall.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Scripts.pm
inc/Module/Install/Win32.pm
Expand All @@ -35,6 +38,7 @@ lib/Vimana/GitInstall.pm
lib/Vimana/Index.pm
lib/Vimana/Installer.pm
lib/Vimana/Installer/Auto.pm
lib/Vimana/Installer/Makefile.pm
lib/Vimana/Installer/Meta.pm
lib/Vimana/Installer/Rakefile.pm
lib/Vimana/Installer/Text.pm
Expand All @@ -48,9 +52,9 @@ lib/Vimana/VimOnline.pm
lib/Vimana/VimOnline/ScriptPage.pm
lib/Vimana/VimOnline/Search.pm
lwp.pl
Makefile
Makefile.PL
MANIFEST This list of files
MANIFEST.bak
MANIFEST.SKIP
META.yml
README.mkd
t/00-commands.t
Expand All @@ -72,4 +76,3 @@ vimana-specky-log
xt/installer-makefile-2.t
xt/installer-makefile-3.t
xt/installer-makefile.t
Makefile.PL
2 changes: 1 addition & 1 deletion Makefile.PL
Expand Up @@ -24,7 +24,7 @@ requires
'YAML' => 0,
'Digest::MD5' => 0,
'JSON' => 0,
'JSON::XS' => 0,
'JSON::PP' => 0,
'HTTP::Lite' => 0,
'Mouse' => 0;

Expand Down
11 changes: 8 additions & 3 deletions lib/Vimana/Record.pm
Expand Up @@ -2,11 +2,15 @@ package Vimana::Record;
use warnings;
use strict;
use Vimana;
use JSON::XS;
use JSON;
use JSON::PP;
use File::Path;
use Digest::MD5 qw(md5_hex);
use YAML;

sub new_json {
return JSON::PP->new->allow_singlequote(1);
}

sub record_dir {
return ( $ENV{VIM_RECORD_DIR} || File::Spec->join($ENV{HOME},'.vim','record') );
Expand Down Expand Up @@ -49,6 +53,7 @@ spec:
=cut


sub load {
my ( $class, $pkgname ) = @_;
my $record_file = $class->record_path( $pkgname );
Expand All @@ -64,7 +69,7 @@ sub load {
close FH;

my $record;
eval { $record = decode_json( $json ) };
eval { $record = new_json()->decode( $json ) };
if( $@ ) {
# try to load YAML. (old record file)
print STDERR $@;
Expand Down Expand Up @@ -117,7 +122,7 @@ sub add {
return 0 if -f $record_file;

open FH , ">" , $record_file;
print FH encode_json( $record );
print FH new_json()->encode( $record );
close FH;

#return YAML::DumpFile( $record_file , $record );
Expand Down

0 comments on commit 19924d1

Please sign in to comment.