java怎么将string或json转出xml?

wenwen1 发布于 2014/10/14 10:22
阅读 334
收藏 2

传到后台的数据如下:

{"f1_date":"20140101","f2_Appl":"222","f3_orign":"22","f5_branch":"a","f6_location":"China","f7_ccif":"c      ","f8_lineOB":"22","f9_obligor":"22","f10_moody":"22","f12_locationCountry":"China","f13_cifNo":"1011821","f14_lineOfBusiness":"33","f15_customer":"33","f161_limitCcyCode":"OT","f162_amount":"121000","f17_typeOfProduct":"1","f18_tenor":"22","f19_importer":"22","f20_location":"22","f21_commodity":"22","f22_issuingDate":"22","f23_expiryDate":"22","f24_latest":"22","f25_shipment":"22","f26_number":"22","f27_ourRefNo":"22","f28_discount":"22","f29_terms":"22","f30_execution":"20140810","f31_confirmation":"20141010","f32_acceptance":"20141110","f33_forfaiting":"20141210","f34_book":"","f35_bank":"","f36_interest":"","f37_commitment":"","f38_other":"","f39_reasons":""}

在后台怎么讲上述的字符串改成如下的格式的xml

<profile>
  <f1_date>sffdsf</f1_date>
  <f2_Appl>dfsfsdf</f2_Appl>
  <f3_orign>sfsdffffff</f3_orign>
  <f17_typeOfProduct>1</f17_typeOfProduct>
</profile>

加载中
0
醒醒盹
醒醒盹
好像不能直接转吧,先转成对象吧
0
演绎璀璨人生
演绎璀璨人生
将json转成Map对象,再转成xml。可以使用XStream,很简单。
0
sxgkwei
sxgkwei
新建一个java类profile,有4个属性,然后把json转换成这个对象的集合,然后再把java集合转换成xml,都是工具jar来做的,但中间你需要建立一个java中转对象。
返回顶部
顶部