             }
 
             let key: String
-            if head() == Literal.DOUBLE_QUOTE {
+            if loc < input.count && input[loc] == Literal.DOUBLE_QUOTE {
                 switch decodeString() {
                 case .Ok(let json):
                     key = json.string!

        while loc < input.count {
            skipWhitespace()

            if head() == Literal.RIGHT_BRACE {
                ++loc
                var obj = [String:JSON](minimumCapacity: pairs.count)
                for (k, v) in pairs {

            }

            skipWhitespace()
            if loc < input.count && input[loc] == Literal.COLON {
                ++loc
            } else {
                return makeParseError("invalid object at position \(start) - missing `:` between key and value")
