                 data = try self.encoder.encode(container)
             } else {
                 let container = try V1(pins: pins, mirrors: mirrors)
-                data = try self.encoder.encode(container)
+                let json = container.toLegacyJSON()
+                let bytes = json.toBytes(prettyPrint: true)
+                data = Data(bytes.contents)
             }
 #if !os(Windows)
             // rdar://83646952: add newline for POSIXy systems

            )
        }

        struct Container: Codable {
            var pins: [Pin]
        }

        struct Pin: Codable {

                // rdar://52529014, rdar://52529011: pin file should store the original location but remap when loading
                self.repositoryURL = mirrors.originalURL(for: location) ?? location
                self.state = try .init(pin.state)
            }

            // backwards compatibility of JSON format
            func toLegacyJSON() -> JSON {
                return .init([
                    "package": self.package.toJSON(),
                    "repositoryURL": self.repositoryURL.toJSON(),
                    "state": self.state.toLegacyJSON()
                ])
            }
        }

