File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 11//
2- // BOMDoubling .swift
2+ // JSONSerialization+BOM .swift
33// swift-transformers
44//
55// Created by Pedro Cuenca on 20250912
66//
77
88import 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- }
You can’t perform that action at this time.
0 commit comments