-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJsonStringParseToPojo.java
More file actions
47 lines (32 loc) · 969 Bytes
/
JsonStringParseToPojo.java
File metadata and controls
47 lines (32 loc) · 969 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package example01;
import java.util.List;
import com.shimizukenta.jsonhub.JsonHub;
public class JsonStringParseToPojo {
public int num;
public String str;
public boolean bool;
public Object nul;
public List<String> list;
protected float not_parse_because_not_public;
public static long not_parse_because_static = -1L;
public JsonStringParseToPojo() {
not_parse_because_not_public = -1.0F;
}
@Override
public String toString() {
return "{"
+ "num: " + num
+ ", str: \"" + str
+ "\", bool: " + bool
+ ", nul: " + nul
+ ", list.size(): "
+ (list == null ? -1 : list.size())
+ "}";
}
public static void main(String[] args) {
String json = "{\"num\": 100, \"str\": \"string\", \"bool\": true, \"nul\": null, \"list\": [\"a\", \"b\", \"c\"]}";
System.out.println(json);
JsonStringParseToPojo pojo = JsonHub.fromJson(json).toPojo(JsonStringParseToPojo.class);
System.out.println(pojo);
}
}