回答編集履歴

1

追記

2017/06/21 00:55

投稿

root_jp
root_jp

スコア4666

test CHANGED
@@ -25,3 +25,141 @@
25
25
  [http://qiita.com/opengl-8080/items/b613b9b3bc5d796c840c](http://qiita.com/opengl-8080/items/b613b9b3bc5d796c840c)
26
26
 
27
27
  [http://www.nilab.info/z3/20150617_01_java_json_object_mapping_by_jackson.html](http://www.nilab.info/z3/20150617_01_java_json_object_mapping_by_jackson.html)
28
+
29
+
30
+
31
+ ###追記
32
+
33
+ 1つ目のクラス
34
+
35
+ ```java
36
+
37
+ import java.util.List;
38
+
39
+
40
+
41
+ import com.fasterxml.jackson.annotation.JsonProperty;
42
+
43
+
44
+
45
+ public class JavaObjectClass {
46
+
47
+
48
+
49
+ @JsonProperty("@id")
50
+
51
+ private String id;
52
+
53
+
54
+
55
+ @JsonProperty("@name")
56
+
57
+ private String name;
58
+
59
+
60
+
61
+ @JsonProperty("CLASS")
62
+
63
+ private List<InnerObject> classList;
64
+
65
+
66
+
67
+ public JavaObjectClass() {
68
+
69
+ }
70
+
71
+
72
+
73
+ public JavaObjectClass(String id, String name) {
74
+
75
+ this.id = id;
76
+
77
+ this.name = name;
78
+
79
+ }
80
+
81
+
82
+
83
+ //アクセッサ
84
+
85
+ public void setId(String id) {this.id = id;}
86
+
87
+ public String getId() {return id;}
88
+
89
+ public void setName(String name) {this.name = name;}
90
+
91
+ public String getName() {return name;}
92
+
93
+ public void setClassList(List<InnerObject> classList) { this.classList = classList; }
94
+
95
+ public List<InnerObject> getClassList() { return classList; }
96
+
97
+ }
98
+
99
+ ```
100
+
101
+ 2つ目のクラス
102
+
103
+ ```java
104
+
105
+ import com.fasterxml.jackson.annotation.JsonIgnore;
106
+
107
+ import com.fasterxml.jackson.annotation.JsonProperty;
108
+
109
+
110
+
111
+ public class InnerObject {
112
+
113
+ @JsonProperty("@code")
114
+
115
+ private String code;
116
+
117
+ @JsonProperty("@name")
118
+
119
+ private String name;
120
+
121
+ @JsonProperty("@level")
122
+
123
+ private String level;
124
+
125
+ @JsonIgnore
126
+
127
+ private String parentCode;
128
+
129
+
130
+
131
+ public InnerObject() {
132
+
133
+ }
134
+
135
+
136
+
137
+ public InnerObject(String code, String name, String level, String parentCode) {
138
+
139
+ this.code = code;
140
+
141
+ this.name = name;
142
+
143
+ this.level = level;
144
+
145
+ }
146
+
147
+
148
+
149
+ //アクセッサ
150
+
151
+ public String getCode() {return code;}
152
+
153
+ public void setCode(String code) {this.code = code;}
154
+
155
+ public String getName() {return name;}
156
+
157
+ public void setName(String name) {this.name = name;}
158
+
159
+ public String getLevel() {return level;}
160
+
161
+ public void setLevel(String level) {this.level = level;}
162
+
163
+ }
164
+
165
+ ```