additional examples
This commit is contained in:
parent
49658f7750
commit
9d1002385c
@ -0,0 +1,25 @@
|
|||||||
|
package org.baeldung.jackson.sandbox;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
public class SandboxTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public final void whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
|
||||||
|
final TestElement testElement = new TestElement();
|
||||||
|
testElement.setX(10);
|
||||||
|
testElement.setY("adasd");
|
||||||
|
final ObjectMapper om = new ObjectMapper();
|
||||||
|
final String serialized = om.writeValueAsString(testElement);
|
||||||
|
System.err.println(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.baeldung.jackson.sandbox;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
public class TestElement {
|
||||||
|
|
||||||
|
int x;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String y;
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(final int x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(final String y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user