         guard currentValue.underlying != nil else {return JSONValue(underlying: nil,path : self.path + path)}
         for component in path.content {
             currentPath.append(component)
-            if let c = component as? String, let v = currentValue.underlying as? Dictionary<String,AnyObject> {
-                if let newValue = v[c] {
+            switch (component, currentValue.underlying) {
+            case (.Key(let key), let v as Dictionary<String,AnyObject>):
+                if let newValue = v[key] {
                     currentValue = JSONValue(underlying: newValue,path : currentPath)
                 } else {
                     return JSONValue(underlying: nil,path : currentPath)
                 }
-            } else if let c = component as? Int, let v = currentValue.underlying as? Array<AnyObject> {
-                if c < v.count {
-                    currentValue = JSONValue(underlying: v[c],path : currentPath)
+            case (.Index(let index), let v as Array<AnyObject>):
+                if index < v.count {
+                    currentValue = JSONValue(underlying: v[index],path : currentPath)
                 } else {
                     return JSONValue(underlying: nil,path : self.path + path)
                 }
-            } else {
+            default:
                 return JSONValue(underlying: nil,path : self.path + path)
             }
         }


}

public func +(var lhs: JSONPath, rhs: JSONPath) -> JSONPath {
    lhs.append(rhs)
    return lhs
}
public func +(var lhs: JSONPath, rhs: JSONPathComponent) -> JSONPath {
    lhs.append(rhs)
    return lhs
}


        self.content = []
    }
    public init(_ component: String) {
        self.content = [JSONPathComponent(component)]
    }
    public init(_ component: Int) {
        self.content = [JSONPathComponent(component)]
    }
    public init(_ path: JSONPath) {
        self.content = path.content
