2 // JSONViewCommand.swift
5 // Created by Hori,Masaki on 2017/01/19.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
13 class JSONViewCommand: JSONCommand {
14 let jsonTree: [JSONNode]?
15 let parameterList: [Any]
16 let recieveDate: Date?
17 let command: JSONCommand
19 init(apiResponse: APIResponse, command: JSONCommand) {
20 self.recieveDate = Date()
21 self.parameterList = apiResponse
23 .map { ["key": $0.0, "value": $0.1] }
24 self.jsonTree = JSONNode
25 .nodeWithJSON(apiResponse.json as AnyObject?)
27 self.command = command
28 super.init(apiResponse: apiResponse)
31 required init(apiResponse: APIResponse) {
32 fatalError("use init(apiResponse:command:)")
35 override func execute() {
40 print("JSONTracker Cought Exception -> \(error)")
43 guard let _ = jsonTree else { return print("jsonTree is nil.") }
44 guard let _ = recieveDate else { return print("recieveDate is nil.") }
46 DispatchQueue.main.async {
47 let commands: [String: Any] = [
49 "argument": self.parameterList,
50 "json": self.jsonTree ?? [],
51 "recieveDate": self.recieveDate ?? Date(),
54 AppDelegate.shared.jsonViewWindowController?.setCommand(commands)