回答編集履歴
1
追記
test
CHANGED
@@ -33,3 +33,81 @@
|
|
33
33
|
]
|
34
34
|
|
35
35
|
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
こういう書き方もできます。(なお、[String: Any] は Dictionary<String, Any> と同じです。)
|
40
|
+
|
41
|
+
が、params["list"] は Any なので、params["list"][0]["key"] = 〜 とは書けません。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```swift
|
46
|
+
|
47
|
+
var params = [String: Any]()
|
48
|
+
|
49
|
+
params["list"] = [
|
50
|
+
|
51
|
+
[
|
52
|
+
|
53
|
+
"key": "update_datetime",
|
54
|
+
|
55
|
+
"asc": true
|
56
|
+
|
57
|
+
]
|
58
|
+
|
59
|
+
]
|
60
|
+
|
61
|
+
params["paging"] = [
|
62
|
+
|
63
|
+
"pageSize": 100,
|
64
|
+
|
65
|
+
"pageNo": 1
|
66
|
+
|
67
|
+
]
|
68
|
+
|
69
|
+
params["no"] = 1
|
70
|
+
|
71
|
+
params["admin"] = true
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
御所望の書き方は、[SwiftyJSON](https://github.com/SwiftyJSON/SwiftyJSON) を使えばできるかと。
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```swift
|
82
|
+
|
83
|
+
import SwiftyJSON
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
var params = JSON()
|
88
|
+
|
89
|
+
params["list"] = [JSON()]
|
90
|
+
|
91
|
+
params["list"][0]["key"] = "update_datetime"
|
92
|
+
|
93
|
+
params["list"][0]["asc"] = true
|
94
|
+
|
95
|
+
params["paging"] = JSON()
|
96
|
+
|
97
|
+
params["paging"]["pageSize"] = 100
|
98
|
+
|
99
|
+
params["paging"]["pageNo"] = 1
|
100
|
+
|
101
|
+
params["no"] = 1
|
102
|
+
|
103
|
+
params["admin"] = true
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
if let data = try? params.rawData() {
|
108
|
+
|
109
|
+
print(String(data: data, encoding: .utf8)!)
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
```
|