http://qs321.pair.com?node_id=773972


in reply to Re: Converting boolean values in XMLout
in thread Converting boolean values in XMLout

You'll need to walk the structure

For which there is the fine Data::Rmap module:

use strict; use warnings; use JSON; use XML::Simple; use Data::Rmap qw(rmap_ref); use Data::Dumper; my $text = '{"a":"x","b":true}'; my $result = decode_json($text); print Dumper($result); rmap_ref { $_ = "$_" if JSON::is_bool($_) } $result; # or numify, like + ikegami shows above print Dumper($result); my $rec = XMLout( $result, RootName => 'root', SuppressEmpty => 1); print Dumper($rec);

Output:

$VAR1 = { 'a' => 'x', 'b' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ) }; $VAR1 = { 'a' => 'x', 'b' => 'true' }; $VAR1 = '<root a="x" b="true" /> ';