import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
public class JacksonObjectMapper {
@Getter
public static class User {
String name;
int age;
}
public static void main(String[] strings) throws JsonProcessingException {
User user = new User();
user.name = "sam";
user.age = 25;
ObjectMapper objectMapper = new ObjectMapper();
System.out.println(objectMapper.writeValueAsString(user));
}
}
//Output
{"name":"sam","age":25}