{ "a": "x", "b": { "c":true, "d":false, "e":true, "f":false } } #### $VAR1 = { 'a' => 'x', 'b' => { 'e' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), 'c' => $VAR1->{'b'}{'e'}, 'd' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ), 'f' => $VAR1->{'b'}{'d'} } }; $VAR1 = { 'a' => 'x', 'b' => { 'e' => 'true', 'c' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), 'd' => 'false', 'f' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ) } }; Can't encode a value of type: JSON::XS::Boolean at test2.pl line 13 #### use strict; use warnings; use JSON; use XML::Simple; use Data::Rmap qw(rmap_ref); use Data::Dumper; my $text = '{"a":"x","b":{"c":true,"d":false,"e":true,"f":false}}'; my $result = decode_json($text); print Dumper($result); rmap_ref { $_ = "$_" if JSON::is_bool($_) } $result; print Dumper($result); rmap_ref { $_ = "$_" if JSON::is_bool($_) } $result; print Dumper($result); my $rec = XMLout( $result, RootName => 'root', SuppressEmpty => 1); print Dumper($rec); #### $VAR1 = { 'a' => 'x', 'b' => { 'e' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), 'c' => $VAR1->{'b'}{'e'}, 'd' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ), 'f' => $VAR1->{'b'}{'d'} } }; $VAR1 = { 'a' => 'x', 'b' => { 'e' => 'true', 'c' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), 'd' => 'false', 'f' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ) } }; $VAR1 = { 'a' => 'x', 'b' => { 'e' => 'true', 'c' => 'true', 'd' => 'false', 'f' => 'false' } }; $VAR1 = ' '; #### elsif (JSON::XS::is_bool($node)) { #$node += 0; # this results in 1 or 0 #$node = "$node"; # this results in "true" or "false" $node = ($node) ? \1 : \0; # this results in \1 or \0 (which are mapped to Json true and false by encode_json...) }