标签:out encoding use pen sim name version 字符 json2
#!/usr/bin/perl
use strict;
use JSON::Any;
use XML::Simple;
my $json = ‘{"name":"zhumao","pass":"123","other":[{"a0":"a0a0a0","b0":"b0b0b0"},{"a1":"a1a1a1","b1":"b1b1b1"}]}‘;
$json=~s/[\x00-\x1f]//g;#过滤不可见字符
my $convertor = JSON::Any->new();
my $data = $convertor->decode($json);
my $xml = XMLout($data);#生成xml
open(O,">:utf8","test.xml");#将xml写入文件(如果有中文,需要加:utf8)
print O qq#<?xml version="1.0" encoding="UTF-8"?>\n#;
print O $xml;
close(O);
注:不要使用JSON2XML,很难用。
标签:out encoding use pen sim name version 字符 json2
原文地址:https://www.cnblogs.com/zhumao/p/9737729.html