@@ -22,7 +22,7 @@ Add the following to your `Package.swift` file:
2222
2323``` swift
2424dependencies: [
25- .package (url : " https://github.com/loopwork-ai /JSONLines.git" , from : " 1.0.0" )
25+ .package (url : " https://github.com/loopwork/JSONLines.git" , from : " 1.0.0" )
2626]
2727```
2828
4747 // Get a byte stream from a URL or file
4848 let url = URL (string : " https://example.com/todos.jsonl" )!
4949 let (stream, _ ) = try await URLSession.shared .bytes (for : URLRequest (url : url))
50-
50+
5151 // Process each JSON line as it arrives
5252 for try await todo in stream.jsonLines (decoding : Todo.self ) {
5353 print (" Todo #\( todo.id ) : \( todo.title ) \( todo.completed ? " ✓ Completed" : " " ) " )
@@ -73,11 +73,11 @@ Task {
7373 // Set up a custom decoder with date decoding strategy
7474 let decoder = JSONDecoder ()
7575 decoder.dateDecodingStrategy = .iso8601
76-
76+
7777 // Get data from a file
7878 let fileURL = URL (fileURLWithPath : " /path/to/logs.jsonl" )
7979 let data = try Data (contentsOf : fileURL)
80-
80+
8181 // Process the JSON Lines with the custom decoder
8282 for try await entry in data.jsonLines (decoding : LogEntry.self , with : decoder) {
8383 print (" [\( entry.timestamp ) ] [\( entry.level ) ] \( entry.message ) " )
@@ -112,7 +112,7 @@ Task {
112112 for try await dataPoint in fileHandle.bytes.jsonLines (decoding : DataPoint.self ) {
113113 // Process each data point individually
114114 processDataPoint (dataPoint)
115-
115+
116116 count += 1
117117 if count % 1000 == 0 {
118118 print (" Processed \( count ) data points" )
0 commit comments