Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.fasterxml.jackson.databind.ObjectMapper;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class JacksonSimple {
- public static void main(String[] args) {
- readValue();
- }
- private static void readValue() {
- ObjectMapper mapper = new ObjectMapper();
- String filepath = System.getProperty("user.dir") + File.separator
- + "user.json";
- try {
- User user = (User) mapper.readValue(new FileInputStream(filepath),
- User.class);
- System.out.println(user);
- } catch (IOException ex) {
- Logger.getLogger(JacksonSimple.class.getName())
- .log(Level.SEVERE, null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement