Java json 转xml

jar 下载:
http://download.csdn.net/detail/capmiachael/9858840

package com.as;

import org.json.JSONObject;
import org.json.XML;

public class Test {
public static void main(String[] args) {
    String jsonString="{\"SALE_AMT1\":\"288\",\"SALE_AMT2\":\"288\",\"SALE_SO_ID\":\"X1000511G1705263645\",\"SALE_REAL_AMT\":\"288\",\"QTY\":\"1\",\"SALE_TOP_SO_ID\":\"X1000511G1705263645\",\"POS_ID\":\"G\",\"SALE_FLG\":\"销售\",\"SALE_STAFF\":\"100000\",\"DPET_ID\":\"100051\",\"CHECKOUT_DT\":\"2017-05-26 19:16:03\",\"REASON_NAME\":\"\",\"PROM_ID\":\"\",\"STD_PRICE\":\"288\",\"PROM_ID1\":\"\",\"ITEM_ID\":\"600000112\",\"PROM_NAME\":\"\",\"PROM_SET_SOT\":\"\"}";
    JSONObject json =new JSONObject(jsonString);
    String xml = XML.toString(json);
    System.out.println(xml);
}

}

结果:

<DPET_ID>100051DPET_ID><POS_ID>GPOS_ID><PROM_ID1/><SALE_STAFF>100000SALE_STAFF><PROM_ID/><STD_PRICE>288STD_PRICE><ITEM_ID>600000112ITEM_ID><SALE_AMT1>288SALE_AMT1><SALE_SO_ID>X1000511G1705263645SALE_SO_ID><SALE_AMT2>288SALE_AMT2><CHECKOUT_DT>2017-05-26 19:16:03CHECKOUT_DT><REASON_NAME/><SALE_FLG>销售SALE_FLG><QTY>1QTY><PROM_NAME/><SALE_TOP_SO_ID>X1000511G1705263645SALE_TOP_SO_ID><SALE_REAL_AMT>288SALE_REAL_AMT><PROM_SET_SOT/>

附录 :各种语言的 均可在 http://json.org/ 找到

你可能感兴趣的:(---------【Java】,◆编程语言)