#!/usr/bin/perljson
use strict;
use JSON::Any;
use XML::Simple;code
my $json = '{"name":"zhumao","pass":"123","other":[{"a0":"a0a0a0","b0":"b0b0b0"},{"a1":"a1a1a1","b1":"b1b1b1"}]}';xml
$json=~s/[\x00-\x1f]//g;#過濾不可見字符
my $convertor = JSON::Any->new();
my $data = $convertor->decode($json);
my $xml = XMLout($data);#生成xmlio
open(O,">:utf8","test.xml");#將xml寫入文件(若是有中文,須要加:utf8)
print O qq#<?xml version="1.0" encoding="UTF-8"?>\n#;
print O $xml;
close(O);test
注:不要使用JSON2XML,很難用。coding