https://github.com/fumito-ito/swiftyjsonlines
The better way to deal with JSONLines data in Swift.
https://github.com/fumito-ito/swiftyjsonlines
jsonl jsonlines swift swift6
Last synced: 4 months ago
JSON representation
The better way to deal with JSONLines data in Swift.
- Host: GitHub
- URL: https://github.com/fumito-ito/swiftyjsonlines
- Owner: fumito-ito
- License: apache-2.0
- Created: 2024-10-09T15:00:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-06T12:51:42.000Z (over 1 year ago)
- Last Synced: 2026-02-02T04:49:03.638Z (5 months ago)
- Topics: jsonl, jsonlines, swift, swift6
- Language: Swift
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftyJSONLines
The better way to deal with JSONLines data in Swift.
## Installation
### Swift Package Manager
```swift
let package = Package(
name: "MyPackage",
products: [...],
targets: [
.target(
"YouAppModule",
dependencies: [
.product(name: "SwiftyJSONLines", package: "SwiftyJSONLines")
]
)
],
dependencies: [
.package(url: "https://github.com/fumito-ito/SwiftyJSONLines.git", .upToNextMajor(from: "0.0.1"))
]
)
```
## Usage
```swift
// You can parse and iterate json objects from jsonl format string.
let jsonlines = try JSONLines(jsonString)
for json in jsonlines.toDictionaries() {
print(json) // => [String: Any] object
}
// Ofcourse, you can get json lines from data,
let jsonlinesFromData = try JSONLines(data: jsonStringData)
// local file...
let jsonlinesFromLocalPath = try JSONLines(contentsOfFile: "/path/to/example.jsonl")
// and remote file
let jsonlinesFromRemoteFile = try await JSONLines(contensOf: URL(string: "https://example.com/path/to/example.jsonl"))
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/)