This commit is contained in:
Eko Haryadi
2025-08-20 08:56:18 +07:00
parent 4496edd8c8
commit be06f273c5
36 changed files with 3486 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package id.co.iconpln.apkt.data309.utils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
public class XmlToJsonConverter {
public static String convertXmlToJson(String xmlString) throws Exception {
// Create an XML mapper
XmlMapper xmlMapper = new XmlMapper();
// Read XML string into JSON
JsonNode jsonNode = xmlMapper.readTree(xmlString.getBytes());
// Create an Object Mapper
ObjectMapper objectMapper = new ObjectMapper();
// Convert JSON node to JSON string
return objectMapper.writeValueAsString(jsonNode);
}
}