We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As shown below, the boolean getters starting with 'is' are ignored, but should be included in the json. This is in 1.0.1 and 1.1.0.
package com.pros.travel.commons.dropwizard.cassandra.dao; import static com.monitorjbl.json.Match.match; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.monitorjbl.json.JsonView; import com.monitorjbl.json.JsonViewModule; public class JsonViewDemo { public static void main(String[] args) throws JsonProcessingException { // Prints // {"name":"Antartica","code":"AQ","active":true,"computedLabel":"asdf"} printWithJackson(); // Prints // {"name":"Antartica","computedLabel":"asdf"} // and misses the 'active' property printWithJsonView(); } private static void printWithJackson() throws JsonProcessingException { Pojo1 pojo1 = new Pojo1(); ObjectMapper objectMapper = new ObjectMapper(); System.out.println(objectMapper .writeValueAsString(pojo1)); } private static void printWithJsonView() throws JsonProcessingException { Pojo1 pojo1 = new Pojo1(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JsonViewModule()); System.out.println(objectMapper .writeValueAsString( JsonView.with(pojo1).onClass(pojo1.getClass(), match().exclude("code")))); } } class Pojo1 { private String name = "Antartica"; private String code = "AQ"; private boolean active = true; public String getComputedLabel() { return "asdf"; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } public boolean isActive() { return active; } public void setActive(boolean active) { this.active = active; } }
I am suspecting that line from JsonViewSerializer
getDeclaredMethods(cls).stream() .filter(m -> m.getName().startsWith("get") && !m.getReturnType().equals(Void.class) && m.getParameters().length == 0)
I cant tweak JsonView with @JsonAutoDetect since that jackson annotation would change our existing jackson serialization.
The text was updated successfully, but these errors were encountered:
@monitorjbl any update on this issue? facing same issue with boolean fields.
Sorry, something went wrong.
No branches or pull requests
As shown below, the boolean getters starting with 'is' are ignored, but should be included in the json.
This is in 1.0.1 and 1.1.0.
I am suspecting that line from JsonViewSerializer
I cant tweak JsonView with @JsonAutoDetect since that jackson annotation would change our existing jackson serialization.
The text was updated successfully, but these errors were encountered: