我正在使用的 JSON 数据结构中有布尔值。当调用decode_json将其转换为 Perl 数据结构并提供给XMLout提供的函数时XML::Simple,它会抛出错误,因为XMLout它不知道如何处理JSON::XS::Boolean值。
有没有办法将JSON::XS::Boolean数据结构中的值转换为 XML?
my $text = '{"a":"x","b":true}';
my $result = decode_json($text);
my $rec = XMLout( $result, RootName => 'root', SuppressEmpty => 1);
在上面的代码中,我收到以下错误 -无法编码类型的值:JSON::XS::Boolean
Aprint Dumper $result给出:
$result = {
'a' => 'x',
'b' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' )
};