Before After { { incidentAbstract => 'string' abstract => 'string' } } #### #!/usr/bin/perl -w use strict; use Data::Dumper; # Testing JSON filter_json_object method, to convert 'field names'. use JSON::XS; my $sub = sub { my $jsRef = shift; my %map = (one => 'uno', two => 'dos', three => 'tres'); my $hRef; foreach my $k (keys %$jsRef) { $$hRef{$map{$k}} = $$jsRef{$k}; } return $hRef; }; my $hRef = {one => 1, two => 2, three => 3}; print Dumper ($hRef), "\n\n"; #my $json = JSON:XS->new->filter_json_object->encode ($hRef); my $json = JSON::XS->new->allow_nonref->filter_json_object ($sub); my $jsonStr = $json->encode ($hRef); #print "$jsonStr\n"; my $newHRef = $json->decode ($jsonStr); print Dumper ($newHRef); --- $VAR1 = { 'three' => 3, 'one' => 1, 'two' => 2 }; $VAR1 = { 'uno' => 1, 'dos' => 2, 'tres' => 3 };