Skip to content

Commit 24dcb7d

Browse files
committed
Use JSONEncoder/JSONDecoder makeWithDefaults()
1 parent 62a32e8 commit 24dcb7d

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Sources/Commands/SwiftPackageRegistryTool.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,15 @@ public struct SwiftPackageRegistryTool: ParsableCommand {
150150
private extension Decodable {
151151
static func readFromJSONFile(in fileSystem: FileSystem, at path: AbsolutePath) throws -> Self {
152152
let content = try fileSystem.readFileContents(path)
153-
154-
let decoder = JSONDecoder()
155-
153+
let decoder = JSONDecoder.makeWithDefaults()
156154
return try decoder.decode(Self.self, from: Data(content.contents))
157155
}
158156
}
159157

160158
private extension Encodable {
161159
func writeToJSONFile(in fileSystem: FileSystem, at path: AbsolutePath) throws {
162-
let encoder = JSONEncoder()
163-
encoder.outputFormatting = [.sortedKeys, .prettyPrinted, .withoutEscapingSlashes]
164-
160+
let encoder = JSONEncoder.makeWithDefaults()
165161
let data = try encoder.encode(self)
166-
167162
try fileSystem.writeFileContents(path, bytes: ByteString(data), atomically: true)
168163
}
169164
}

0 commit comments

Comments
 (0)