jackson cleanup work
This commit is contained in:
parent
9d1002385c
commit
31fd5453a5
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -16,6 +17,8 @@ public class SandboxTest {
|
||||||
testElement.setX(10);
|
testElement.setX(10);
|
||||||
testElement.setY("adasd");
|
testElement.setY("adasd");
|
||||||
final ObjectMapper om = new ObjectMapper();
|
final ObjectMapper om = new ObjectMapper();
|
||||||
|
om.setVisibilityChecker(om.getSerializationConfig().getDefaultVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE));
|
||||||
|
|
||||||
final String serialized = om.writeValueAsString(testElement);
|
final String serialized = om.writeValueAsString(testElement);
|
||||||
System.err.println(serialized);
|
System.err.println(serialized);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package org.baeldung.jackson.sandbox;
|
package org.baeldung.jackson.sandbox;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
public class TestElement {
|
public class TestElement {
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@JsonIgnore
|
private transient String y;
|
||||||
private String y;
|
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
|
|
Loading…
Reference in New Issue