Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Benchmarks/NSFoundationDarwin/Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension User.Friend {

public init(json: Any) throws {
guard
let json = json as? [String: Any],
let json = json as? NSDictionary,
let id = json["id"] as? Int,
let name = json["name"] as? String
else { throw JSONError.typeMismatch }
Expand All @@ -23,7 +23,7 @@ extension User {

public init(json: Any) throws {
guard
let json = json as? [String: Any],
let json = json as? NSDictionary,
let id = json["_id"] as? String,
let index = json["index"] as? Int,
let guid = json["guid"] as? String,
Expand All @@ -45,7 +45,7 @@ extension User {
let latitude = json["latitude"] as? Double,
let longitude = json["longitude"] as? Double,
let tags = json["tags"] as? [String],
let friendsObjects = json["friends"] as? [Any],
let friendsObjects = json["friends"] as? NSArray,
//let tags = json["tags"].array?.flatMap({ $0.string }) ?? []
//let friends = try json["friends"].array?.map(Friend.init) ?? []
let greeting = json["greeting"] as? String,
Expand Down Expand Up @@ -98,7 +98,7 @@ let modelResults = try bench { bytes in
let data = Data(bytes: bytes)

let json: Any = try JSONSerialization.jsonObject(with: data)
guard let array = json as? [Any] else { fatalError() }
guard let array = json as? NSArray else { fatalError() }
_ = try array.map(User.init)
}

Expand Down