<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.0</version>
</dependency>
public static JSONObject xmlcConvertJson (String xml) {
XmlMapper xmlMapper = new XmlMapper();
JsonNode jsonNode = null;
try {
jsonNode = xmlMapper.readTree(xml);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return JSONObject.parseObject(jsonNode.toString(), JSONObject.class);
}
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
public static String readContent(String jsonString)throws IOException {
JAXBContext context = JAXBContext.newInstance(STUDENT.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
STUDENT student = (STUDENT)unmarshaller.unmarshal(new StringReader(jsonString));
return requestJsonStr;
}