Skip to content

Instantly share code, notes, and snippets.

@imyaman
Created April 5, 2018 02:17
Show Gist options
  • Save imyaman/11cc48649976beee2e5bf082dee6cb81 to your computer and use it in GitHub Desktop.
Save imyaman/11cc48649976beee2e5bf082dee6cb81 to your computer and use it in GitHub Desktop.
perl json han 2
#!/usr/bin/env perl
use utf8;
use strict;
use Encode;
use JSON;
binmode(STDOUT, ":utf8");
my ($line, $content, $perl_hashref, %perl_hash, $key, $json);
$content = qq/ {"Name":"Sangyong Gwak","성명":"곽상용"} /;
print $content;
print "\n" . " ---- ---- ---- ----" . "\n";
$content = Encode::encode_utf8($content);
$perl_hashref = decode_json($content);
%perl_hash = %{$perl_hashref};
for $key (sort keys %perl_hash){
print $key . " : " . $perl_hash{$key} . "\n";
}
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment