 extension PinsStore.Pin: JSONMappable, JSONSerializable, Equatable {
     /// Create an instance from JSON data.
     public init(json: JSON) throws {
-        self.packageRef = try json.get("reference")
+        let name: String? = json.get("package")
+        let url: String = try json.get("repositoryURL")
+        let ref = PackageReference(identity: PackageReference.computeIdentity(packageURL: url), path: url)
+        self.packageRef = name.flatMap(ref.with(newName:)) ?? ref
         self.state = try json.get("state")
     }
 
     /// Convert the pin to JSON.
     public func toJSON() -> JSON {
         return .init([
-            "reference": packageRef,
+            "package": packageRef.name.toJSON(),
+            "repositoryURL": packageRef.path,
             "state": state,
         ])
     }


    /// The schema version of the resolved file.
    ///
    /// * 2: Package identity.
    /// * 1: Initial version.
    static let schemaVersion: Int = 2

    /// The path to the pins file.
    fileprivate let pinsFile: AbsolutePath

        self.persistence = SimplePersistence(
            fileSystem: fileSystem,
            schemaVersion: PinsStore.schemaVersion,
            statePath: pinsFile,
            prettyPrint: true)
        pinsMap = [:]
