Skip to content

Commit 03c3b53

Browse files
committed
Rename Hub/BOMDoubling.swift to Hub/Extensions/JSONSerialization+BOM.swift
1 parent f5ec29f commit 03c3b53

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Sources/Hub/BOMDoubling.swift renamed to Sources/Hub/Extensions/JSONSerialization+BOM.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
//
2-
// BOMDoubling.swift
2+
// JSONSerialization+BOM.swift
33
// swift-transformers
44
//
55
// Created by Pedro Cuenca on 20250912
66
//
77

88
import Foundation
99

10-
extension Data {
10+
extension JSONSerialization {
11+
class func bomPreservingJsonObject(with data: Data, options: JSONSerialization.ReadingOptions = []) throws -> Any {
12+
try JSONSerialization.jsonObject(with: data.duplicatingBOMsAfterQuotes, options: options)
13+
}
14+
}
15+
16+
private extension Data {
1117
/// Workaround for https://github.com/huggingface/swift-transformers/issues/116
1218
/// Duplicate a BOM sequence that follows a quote. The first BOM is swallowed by JSONSerialization.jsonObject
1319
/// because it thinks it marks the encoding.
@@ -40,9 +46,3 @@ extension Data {
4046
}
4147
}
4248
}
43-
44-
extension JSONSerialization {
45-
class func bomPreservingJsonObject(with data: Data, options: JSONSerialization.ReadingOptions = []) throws -> Any {
46-
try JSONSerialization.jsonObject(with: data.duplicatingBOMsAfterQuotes, options: options)
47-
}
48-
}

0 commit comments

Comments
 (0)