Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "article": [
- {
- "header": "mindshare payment",
- "items": [
- {
- "title": "Applications workforce",
- "text": "Nulla molestiae aliquid natus libero placeat fugit recusandae tempora et."
- }
- ]
- }
- ]
- }
- if let result = response.result.value as? [String: Any],
- let articleArray = result["article"] as? [[String: Any]],
- let main = articleArray["items"] as? [[String: Any]] {
- for obj in main {
- guard
- let title = obj["title"] as? String,
- let text = obj["text"] as? String,
- else {
- return
- }
- let struct = Articles(title: title, text: text)
- }
- }
- request(YOUR_URL, method: .get).responseJSON { response in
- if response.result.isSuccess {
- print("Response success")
- let yourJSON : JSON = JSON(response.result.value!)
- if yourJSON != JSON.null {
- print("Success: Json not nil")
- self.title = yourJSON["article"]["title"].string
- self.text = yourJSON["article"]["text"].string
- } else {
- print("Not success: Json nil")
- }
- } else {
- print("Error: (String(describing: response.result.error))")
- }
- }
- if let result = response.result.value as? [String: Any],
- let articleArray = result["article"] as? [[String: Any]] {
- articleArray.forEach { (obj: [[String: Any]]) in
- guard let title = obj["title"] as? String,
- let text = obj["text"] as? String,
- else { return }
- let struct = Articles(title: title, text: text)
- }
- }
Add Comment
Please, Sign In to add comment