import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.ion.IonObjectMapper;
public class IonSerializationExample {
public static void main(String[] args) throws Exception {
ObjectMapper objectMapper = new IonObjectMapper();
Person person = new Person("John", 30);
byte[] ionData = objectMapper.writeValueAsBytes(person);
System.out.println(new String(ionData));
Person deserializedPerson = objectMapper.readValue(ionData, Person.class);
System.out.println(deserializedPerson);
}
}
class Person {
private String name;
private int age;
public Person() {
}
public Person(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Person{name='" + name + "', age=" + age + "}";
}
}