package com.dtdream.apiflow.apisix.plugin.util;
import org.json.JSONObject;
import org.json.XML;
public class JsonXmlConverterUtil {
public static String jsonToXml(String jsonString){
JSONObject jsonObject = new JSONObject(jsonString);
return XML.toString(jsonObject, "result");
}
public static String xmlToJson(String xmlString){
JSONObject jsonObject = XML.toJSONObject(xmlString);
return jsonObject.toString();
}
}
pom坐标:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
</dependency>