- or download this
use warnings;
use strict;
...
use Data::Dumper;
my $original = '{"OWNER":"KeyProjects","age1":null,"ht1":null}';
- or download this
my $data = decode_json($original);
print Dumper $original;
print Dumper $desired;
print Dumper $data;
for my $key ( keys % {$data} )
- or download this
{
print "Found a key: $key", $/;
if ( $key =~ /\A (?: age\d+ | ht\d+ ) \z/x )
...
print " -> It matches our regular expression\n";
print " -> Deleting it from data structure\n";
my $value = delete $data->{$key};
- or download this
print Dumper $key;
- or download this
print Dumper $value;
- or download this
print " -> Putting it back under sub-structure with key 'sche
+duled'\n";
$data->{scheduled}{$key} = $value;
- or download this
print Dumper $key;
print Dumper $value;
...
my $desired_data = decode_json( $desired );
is_deeply( $desired_data, $data, "Data structures match" );
done_testing(1);