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 {
52 Logger.shared.log("jsonTree is nil.")
56 guard let _ = recieveDate else {
58 Logger.shared.log("recieveDate is nil.")
63 DispatchQueue.main.async {
65 let commands: [String: Any] = [
66 "api": self.api.debugDescription,
67 "argument": self.parameterList,
68 "json": self.jsonTree ?? [],
69 "recieveDate": self.recieveDate ?? Date(),
72 AppDelegate.shared.jsonViewWindowController?.setCommand(commands)