TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2017 |
SwiftSwift Version | 3.1 |
SPMSupports SPM | ✓ |
Maintained by Mark Malstrom.
A JSON Feed wrapper written in pure Swift. For more information on JSON Feeds, see the JSON Feed specification.
Usage examples can be found in Tests/JSONFeedKitTests.playground
. A quick summary here:
import JSONFeedKit
let requestURL = URL(string: "https://daringfireball.net/feeds/json")!
let urlRequest = URLRequest(url: requestURL)
let session = URLSession(configuration: .default)
let task = session.dataTask(with: urlRequest, completionHandler: { (data, response, error) in
let json = try! JSONSerialization.jsonObject(with: data!, options: [])
let feed = try! Feed(jsonRepresentation: json as! [String : Any])
// Use `feed` and its properties in this callback.
})
task.resume()
You may want to write a parser for extracting a JSON Feed URL from an HTML page. For that, I recomend using Ji
.
Create a new directory where you want your project to live. Use swift package init --type executable
to create set up your package. In your new Package.swift
add the following:
import PackageDescription
let package = Package(
name: "Project Name",
dependencies: [
.Package(url: "https://github.com/roonieone/JSONFeedKit.git", "0.1.2")
]
)
Then use swift package fetch
to download the JSON
dependency and swift package generate-xcodeproj
to create an Xcode Project. For more information on how to use Swift Package Manager with iOS, see this gist.