Skip to content

Commit 9d10023

Browse files
author
eugenp
committed
additional examples
1 parent 49658f7 commit 9d10023

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.baeldung.jackson.sandbox;
2+
3+
import java.io.IOException;
4+
5+
import org.junit.Test;
6+
7+
import com.fasterxml.jackson.core.JsonParseException;
8+
import com.fasterxml.jackson.databind.JsonMappingException;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
11+
public class SandboxTest {
12+
13+
@Test
14+
public final void whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
15+
final TestElement testElement = new TestElement();
16+
testElement.setX(10);
17+
testElement.setY("adasd");
18+
final ObjectMapper om = new ObjectMapper();
19+
final String serialized = om.writeValueAsString(testElement);
20+
System.err.println(serialized);
21+
}
22+
23+
//
24+
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.baeldung.jackson.sandbox;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
5+
public class TestElement {
6+
7+
int x;
8+
9+
@JsonIgnore
10+
private String y;
11+
12+
public int getX() {
13+
return x;
14+
}
15+
16+
public void setX(final int x) {
17+
this.x = x;
18+
}
19+
20+
public String getY() {
21+
return y;
22+
}
23+
24+
public void setY(final String y) {
25+
this.y = y;
26+
}
27+
28+
}

0 commit comments

Comments
 (0)