From 1c71fd70912d488bf9604246fce5676b331e5f0d Mon Sep 17 00:00:00 2001 From: Andrew Lees <32634907+Andrew-Lees11@users.noreply.github.com> Date: Sat, 27 Jan 2018 00:26:19 +0000 Subject: [PATCH] Issue.516 removing SwiftyJSON (#33) --- .gitignore | 4 +++- Package.swift | 2 +- .../CredentialsGitHub/CredentialsGitHub.swift | 16 +++++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index b877b71..67db5fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.xcodeproj/ .build build -Package.resolved \ No newline at end of file +Package.resolved +Packages/ +.DS_Store \ No newline at end of file diff --git a/Package.swift b/Package.swift index d72d432..2439cd9 100644 --- a/Package.swift +++ b/Package.swift @@ -29,7 +29,7 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/IBM-Swift/Kitura-Credentials.git", .upToNextMinor(from: "2.0.0")), + .package(url: "https://github.com/IBM-Swift/Kitura-Credentials.git", .upToNextMinor(from: "2.1.0")), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/CredentialsGitHub/CredentialsGitHub.swift b/Sources/CredentialsGitHub/CredentialsGitHub.swift index 5a7a5d9..507dfa2 100644 --- a/Sources/CredentialsGitHub/CredentialsGitHub.swift +++ b/Sources/CredentialsGitHub/CredentialsGitHub.swift @@ -18,9 +18,6 @@ import Kitura import KituraNet import LoggerAPI import Credentials - -import SwiftyJSON - import Foundation // MARK CredentialsGitHub @@ -106,8 +103,8 @@ public class CredentialsGitHub: CredentialsPluginProtocol { do { var body = Data() try fbResponse.readAllData(into: &body) - var jsonBody = JSON(data: body) - if let token = jsonBody["access_token"].string { + if var jsonBody = try JSONSerialization.jsonObject(with: body, options: []) as? [String : Any], + let token = jsonBody["access_token"] as? String { requestOptions = [] requestOptions.append(.schema("https://")) requestOptions.append(.hostname("api.github.com")) @@ -124,13 +121,10 @@ public class CredentialsGitHub: CredentialsPluginProtocol { do { body = Data() try profileResponse.readAllData(into: &body) - jsonBody = JSON(data: body) - - if let userDictionary = jsonBody.dictionaryObject, - let userProfile = self.createUserProfile(from: userDictionary) { - + if let userDictionary = try JSONSerialization.jsonObject(with: body, options: []) as? [String : Any], + let userProfile = self.createUserProfile(from: userDictionary) { if let delegate = self.userProfileDelegate { - delegate.update(userProfile: userProfile, from: jsonBody.dictionaryValue) + delegate.update(userProfile: userProfile, from: userDictionary) } onSuccess(userProfile)