package com.njust.test.json;

import java.util.Date;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JacksonIgnoreGetter
{

    public static void main(String[] args)
        throws JsonProcessingException
    {
        Project project = new Project("test", new Date(), "admin123");

        ObjectMapper mapper = new ObjectMapper();
        System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(project));

        System.out.println("realPwd:" + project);
    }

}

//console: 可以看出，json格式化后的确看不到真实密码了，但是同时直接获取对象也是不对的了
//{
//    "name" : "test",
//    "startDate" : 1531221386945,
//    "password" : "password",
//    "formatedStartDate" : "2018-07-10 19:16:26"
//    }
//    realPwd:Project(name=test, startDate=Tue Jul 10 19:16:26 CST 2018, password=password)


@@ -859,8 +859,273 @@
 sword)%0A%0A
+%0A//%E6%AD%A3%E7%A1%AE%E7%9A%84%E9%81%BF%E5%85%8D%E5%89%8D%E5%8F%B0%E5%B1%95%E7%A4%BA%E5%AF%86%E7%A0%81%EF%BC%8C%E5%90%8C%E6%97%B6%E5%90%8E%E5%8F%B0%E6%AD%A3%E7%A1%AE%E8%AF%BB%E5%8F%96%E5%AF%86%E7%A0%81%E7%9A%84%E6%96%B9%E6%B3%95(%E4%BB%A5%E4%B8%BA%E5%85%A5%E5%BA%93%E7%AD%89%E6%93%8D%E4%BD%9C%EF%BC%8C%E6%A1%86%E6%9E%B6%E5%A4%84%E7%90%86%E4%BC%9A%E8%87%AA%E5%8A%A8%E8%B0%83%E7%94%A8get%E6%96%B9%E6%B3%95)%0A//%7B%0A//    %22name%22 : %22test%22,%0A//    %22startDate%22 : 1531221582727,%0A//    %22formatedStartDate%22 : %222018-07-10 19:19:42%22%0A//    %7D%0A//    realPwd:Project(name=test, startDate=Tue Jul 10 19:19:42 CST 2018, password=admin123)%0A

Update JacksonIgnoreGetter.java