Skip to content

Instantly share code, notes, and snippets.

@aero aero/json_ordered.pl forked from olegwtf/json_ordered.pl
Last active Aug 29, 2015

Embed
What would you like to do?
json을 읽어 원래 json 필드 순서 유지
use strict;
use Tie::IxHash;
use JSON::PP;
# magic start
my $obj_parser_sub = \&JSON::PP::object;
*JSON::PP::object = sub {
tie my %obj, 'Tie::IxHash';
$obj_parser_sub->(\%obj);
};
# magic end
use Data::Dumper;
my $res = decode_json('{"a":1,"b":2,"c":3}');
print Dumper $res;
$res->{b} = 'xx';
print encode_json($res), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.