我需要用JAVA编写一个程序,根据XML中声明的xsd类型将XML转换为JSON。例如,如果XML字符串为:
<?xml version='1.0' encoding='UTF-8'?>
<student xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<age xsi:type="xs:integer">11</age>
<id xsi:type="xs:string">12</id>
<name xsi:type="xs:string">JavaInterviewPoint</name>
</student>
然后JSON将为:
{
student: {
age: 11,
id: "12",
name: "JavaInterviewPoint"
}
}
任何想法我该怎么做?