additional examples

This commit is contained in:
eugenp 2014-02-13 11:23:54 +02:00
parent 49658f7750
commit 9d1002385c
2 changed files with 53 additions and 0 deletions

View File

@ -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);
}
//
}

View File

@ -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;
}
}