質問編集履歴
8
(追加2017-11-09 12:41)
test
CHANGED
File without changes
|
test
CHANGED
@@ -203,3 +203,31 @@
|
|
203
203
|
Debug.Log("user=" + resData.user.id);// ここでパターン1の[*2]エラー
|
204
204
|
|
205
205
|
```
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
==4パターン目(追加2017-11-09 12:41)==
|
210
|
+
|
211
|
+
using System;
|
212
|
+
|
213
|
+
[Serializable]
|
214
|
+
|
215
|
+
class ResData {
|
216
|
+
|
217
|
+
public string status = "ok";
|
218
|
+
|
219
|
+
public string notice = "";
|
220
|
+
|
221
|
+
public ResUser user;
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
[Serializable]
|
226
|
+
|
227
|
+
class ResUser {
|
228
|
+
|
229
|
+
public int id = 0;
|
230
|
+
|
231
|
+
public string name = "";
|
232
|
+
|
233
|
+
}
|
7
ResData resData = JsonUtility.FromJson<ResData>(json);
test
CHANGED
File without changes
|
test
CHANGED
@@ -196,6 +196,8 @@
|
|
196
196
|
|
197
197
|
```c#
|
198
198
|
|
199
|
+
ResData resData = JsonUtility.FromJson<ResData>(json);
|
200
|
+
|
199
201
|
Debug.Log("user=" + resData.user);// ここが空
|
200
202
|
|
201
203
|
Debug.Log("user=" + resData.user.id);// ここでパターン1の[*2]エラー
|
6
追記2017/11/9 11:56
test
CHANGED
File without changes
|
test
CHANGED
@@ -155,3 +155,49 @@
|
|
155
155
|
|
156
156
|
|
157
157
|
2階層目のuserのjson展開して取得する方法が知りたいです。
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
==3パターン目(追記2017/11/9 11:56)==
|
162
|
+
|
163
|
+
ResDataとResUserを個別のクラスにしましたがパターン1と同様のエラーでした。
|
164
|
+
|
165
|
+
ResData.cs
|
166
|
+
|
167
|
+
```c#
|
168
|
+
|
169
|
+
public class ResData {
|
170
|
+
|
171
|
+
public string status = "ok";
|
172
|
+
|
173
|
+
public string notice = "";
|
174
|
+
|
175
|
+
public ResUser user;
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
```
|
180
|
+
|
181
|
+
ResUser.cs
|
182
|
+
|
183
|
+
```c#
|
184
|
+
|
185
|
+
public class ResUser {
|
186
|
+
|
187
|
+
public int id = 0;
|
188
|
+
|
189
|
+
public string name = "";
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
```
|
194
|
+
|
195
|
+
TestScript.cs
|
196
|
+
|
197
|
+
```c#
|
198
|
+
|
199
|
+
Debug.Log("user=" + resData.user);// ここが空
|
200
|
+
|
201
|
+
Debug.Log("user=" + resData.user.id);// ここでパターン1の[*2]エラー
|
202
|
+
|
203
|
+
```
|
5
tててst
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
|
55
|
+
|
56
56
|
|
57
57
|
```ここに言語を入力
|
58
58
|
|
@@ -65,6 +65,8 @@
|
|
65
65
|
```
|
66
66
|
|
67
67
|
|
68
|
+
|
69
|
+
==1パターン目==
|
68
70
|
|
69
71
|
```c#
|
70
72
|
|
4
うに
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
unityで階層のあるjsonを展開する方法
|
test
CHANGED
File without changes
|
3
2階層目のuserのjson展開して取得する方法が知りたいです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -152,4 +152,4 @@
|
|
152
152
|
|
153
153
|
|
154
154
|
|
155
|
-
2階層目のuserのjson
|
155
|
+
2階層目のuserのjson展開して取得する方法が知りたいです。
|
2
2階層目のuserのjsonを取得する方法が知りたいです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -149,3 +149,7 @@
|
|
149
149
|
|
150
150
|
|
151
151
|
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
2階層目のuserのjsonを取得する方法が知りたいです。
|
1
っっg
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
unityで階層のあるjsonを展開する方法
|
1
|
+
gunityで階層のあるjsonを展開する方法
|
test
CHANGED
@@ -36,11 +36,11 @@
|
|
36
36
|
|
37
37
|
void ExecJsonParse (string json) {
|
38
38
|
|
39
|
-
|
39
|
+
ResData resData = JsonUtility.FromJson<ResData>(json);
|
40
40
|
|
41
|
-
|
41
|
+
Debug.Log("status=" + resData.status);
|
42
42
|
|
43
|
-
|
43
|
+
Debug.Log("notice=" + resData.notice);
|
44
44
|
|
45
45
|
}
|
46
46
|
|
@@ -92,15 +92,15 @@
|
|
92
92
|
|
93
93
|
void ExecJsonParse (string json) {
|
94
94
|
|
95
|
-
|
95
|
+
ResData resData = JsonUtility.FromJson<ResData>(json);
|
96
96
|
|
97
|
-
|
97
|
+
Debug.Log("status=" + resData.status);
|
98
98
|
|
99
|
-
|
99
|
+
Debug.Log("notice=" + resData.notice);
|
100
100
|
|
101
|
-
|
101
|
+
Debug.Log("user=" + resData.user);// *1
|
102
102
|
|
103
|
-
|
103
|
+
Debug.Log("user.id=" + resData.user.id); // *2
|
104
104
|
|
105
105
|
}
|
106
106
|
|
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
|
114
114
|
|
115
|
-
*2のところで
|
115
|
+
*2のところで以下エラーメッセージがでました。
|
116
116
|
|
117
117
|
```ここに言語を入力
|
118
118
|
|
@@ -120,7 +120,7 @@
|
|
120
120
|
|
121
121
|
```
|
122
122
|
|
123
|
-
|
123
|
+
|
124
124
|
|
125
125
|
|
126
126
|
|