当前位置: 代码迷 >> JavaScript >> JSON与JAVA的数据转换 json->xml
  详细解决方案

JSON与JAVA的数据转换 json->xml

热度:134   发布时间:2012-10-26 10:30:58.0
JSON与JAVA的数据转换 json-->xml
6  json to xml
  1)
JSONObject json = new JSONObject( true );  
String xml = XMLSerializer.write( json ); 
< o class="object" null="true"> 
  2)
JSONObject json = JSONObject.fromObject("{"name":"json","bool":true,"int":1}");  
String xml = XMLSerializer.write( json ); 
< o class="object"> 
   < name type="string">json< /name> 
   < bool type="boolean">true< /bool> 
   < int type="number">1< /int> 
< /o> 
   < o class="object"> 
      < name type="string">json< /name> 
      < bool type="boolean">true< /bool> 
      < int type="number">1< /int> 
   < /o> 
  3)
JSONArray json = JSONArray.fromObject("[1,2,3]");  
String xml = XMLSerializer.write( json ); 
< a class="array"> 
   < e type="number">1< /e> 
   < e type="number">2< /e> 
   < e type="number">3< /e> 
< /a> 
  相关解决方案