2 // JSONViewCommand.swift
5 // Created by Hori,Masaki on 2017/01/19.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
13 final class JSONViewCommand: JSONCommand {
15 let jsonTree: [JSONNode]?
16 let parameterList: [Any]
17 let recieveDate: Date?
18 let command: JSONCommand
20 init(apiResponse: APIResponse, command: JSONCommand) {
22 self.recieveDate = Date()
23 self.parameterList = apiResponse
25 .map { ["key": $0, "value": $1] }
26 self.jsonTree = JSONNode
27 .nodeWithJSON(apiResponse.json)
29 self.command = command
31 super.init(apiResponse: apiResponse)
34 required init(apiResponse: APIResponse) {
36 fatalError("use init(apiResponse:command:)")
39 override func execute() {
47 print("JSONTracker Cought Exception -> \(error)")
50 guard let _ = jsonTree else { return Logger.shared.log("jsonTree is nil.") }
51 guard let _ = recieveDate else { return Logger.shared.log("recieveDate is nil.") }
53 DispatchQueue.main.async {
55 let commands: [String: Any] = [
57 "argument": self.parameterList,
58 "json": self.jsonTree ?? [],
59 "recieveDate": self.recieveDate ?? Date(),
62 AppDelegate.shared.jsonViewWindowController?.setCommand(commands)