     case string(String)
     case array(ArrayReader)
     case object(ObjectReader)
+
+    // Deeply inflate this ValueReader into a Value.
+    public var value: Value {
+        switch self {
+        case .integer(let i): return .integer(i)
+        case .double(let d): return .double(d)
+        case .null: return .null
+        case .bool(let b): return .bool(b)
+        case .string(let s): return .string(s)
+        case .array(let reader):
+            var result: [Value] = []
+            result.reserveCapacity(reader.count)
+            for element in reader {
+                result.append(element.value)
+            }
+            return .array(result)
+        case .object(let reader):
+            var result: [String: Value] = [:]
+            for (key, element) in reader {
+                result[key] = element.value
+            }
+            return .object(result)
+        }
+    }
 }
 
 // Encapsulates logic required to read from an array.

}

// Encapsulates logic required to read from an object.
public struct ObjectReader {
    fileprivate init(payload: UnsafePointer<UInt>, input: UnsafeBufferPointer<UInt8>) {
        self.payload = payload
        self.input = input
    }

    public subscript(key: String) -> ValueReader? {

        return result
    }

    // MARK: Sequence

    public struct Iterator: IteratorProtocol {
        fileprivate init(objectReader: ObjectReader) {
            self.objectReader = objectReader
        }

        public mutating func next() -> (String, ValueReader)? {
            if currentIndex < objectReader.count {
                let value = objectReader[currentIndex]
                currentIndex += 1
                return value
            } else {
                return nil
            }
        }

        private var currentIndex = 0
        private let objectReader: ObjectReader
    }
    
    public func makeIterator() -> ObjectReader.Iterator {
        return Iterator(objectReader: self)
    }

    // MARK: Private

    private let payload: UnsafePointer<UInt>
    private let input: UnsafeBufferPointer<UInt8>
}

// MARK: Value

/// Represents a fully-decoded JSON parse tree.  This API is provided for convenience, but for
/// optimal performance, consider using `ValueReader` instead.
public enum Value {
    case integer(Int32)
    case double(Float64)
    case null
    case bool(Bool)
    case string(String)
    case array([Value])
    case object([String: Value])
}

// Internal type that represents a decodable sajson AST node.
private struct ASTNode {
    // Keep this in sync with sajson::type
    private struct RawType {
        static let integer: UInt8 = 0
        static let double: UInt8 = 1
        static let null: UInt8 = 2
        static let bfalse: UInt8 = 3
        static let btrue: UInt8 = 4
        static let string: UInt8 = 5
        static let array: UInt8 = 6
        static let object: UInt8 = 7
    }
    
    fileprivate init(type: UInt8, payload: UnsafePointer<UInt>, input: UnsafeBufferPointer<UInt8>) {
        self.type = type
        self.payload = payload
