我正在尝试从Jackson 2.3升级到Jackson 2.7,似乎@JsonIgnore(Include.NON_DEFAULT)行为已经改变。 使用以下代码
package jackson;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Test {
public static void main (String args[]) throws Exception {
MyClass foo = new MyClass();
ObjectMapper mapper = new ObjectMapper();
System.out.println(mapper.writeValueAsString(foo));
}
public static enum MyEnum { A, B, C };
public static class MyClass {
public String name = "John";
@JsonInclude(Include.NON_DEFAULT)
public MyEnum myEnum = MyEnum.A;
}
}
我使用2.7:
获得此输出{"name":"John","myEnum":"A"}
以及使用2.3:
{"name":"John"}
如何使用2.7版复制2.3中的行为?
答案 0 :(得分:1)
根据我为此提出的the bug ticket,它按预期工作,并且可以通过将您的类结构化来实现功能:
#RewriteEngine On
#RewriteCond %{HTTP_HOST} !^myurl.com$
#RewriteRule ^(.*)$ http://myurl.com/$1 [R=301,L]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://myurl.com/$1 [R,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://myurl.com%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
请参阅故障单以获取作者的更全面解释。