how to serialize with jackson code example
Example: jackson serialize xml
public static void serializeToXML() {
try {
XmlMapper xmlMapper = new XmlMapper();
String xmlString = xmlMapper.writeValueAsString(new PhoneDetails("OnePlus", "6.4", "6/64 GB"));
System.out.println(xmlString);
File xmlOutput = new File("serialized.xml");
FileWriter fileWriter = new FileWriter(xmlOutput);
fileWriter.write(xmlString);
fileWriter.close();
} catch (JsonProcessingException e) {
} catch (IOException e) {
}
}
public static void main(String[] args) {
System.out.println("Serializing to XML...");
serializeToXML();
}