forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestAnnotationJsonIgnore.java
More file actions
32 lines (25 loc) · 900 Bytes
/
TestAnnotationJsonIgnore.java
File metadata and controls
32 lines (25 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.jsoniter;
import com.jsoniter.annotation.JsonIgnore;
import junit.framework.TestCase;
import java.io.IOException;
import java.io.Serializable;
public class TestAnnotationJsonIgnore extends TestCase {
public static class TestObject1 {
@JsonIgnore
public int field2;
}
public void test_ignore() throws IOException {
JsonIterator iter = JsonIterator.parse("{'field2': 100}".replace('\'', '"'));
TestObject1 obj = iter.read(TestObject1.class);
assertEquals(0, obj.field2);
}
public static class TestObject2 {
@JsonIgnore
public Serializable field2;
}
public void test_ignore_no_constructor_field() throws IOException {
JsonIterator iter = JsonIterator.parse("{'field2': 100}".replace('\'', '"'));
TestObject2 obj = iter.read(TestObject2.class);
assertNull(obj.field2);
}
}