We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 999ae83 commit ebbc30dCopy full SHA for ebbc30d
Source/SwiftyJSON.swift
@@ -314,14 +314,7 @@ extension JSON {
314
*/
315
public subscript(path: [SubscriptType]) -> JSON {
316
get {
317
- switch path.count {
318
- case 0: return JSON.null
319
- case 1: return self[sub: path[0]]
320
- default:
321
- var aPath = path; aPath.removeAtIndex(0)
322
- let nextJSON = self[sub: path[0]]
323
- return nextJSON[aPath]
324
- }
+ return path.reduce(self) { $0[sub: $1] }
325
}
326
set {
327
switch path.count {
0 commit comments