Type-safe JSON Feed type definitions for Swift (Version 1.1 specification).
swift-json-feed-standard provides complete JSON Feed 1.1 specification support with type-safe Swift types for representing JSON feed data structures.
For JSON feed generation with type-safe convenience APIs, see swift-json-feed.
- Complete JSON Feed 1.1 Support: All required and optional feed and item elements per JSON Feed 1.1 specification
- Type Safety: Compile-time validation with Hashable, Sendable, Codable conformance
- Validation: Throwing initializers enforce JSON Feed requirements (items require contentHTML OR contentText)
- Swift 6.0 Concurrency: Strict concurrency mode with complete Sendable conformance
Add swift-json-feed-standard to your Package.swift dependencies:
dependencies: [
.package(url: "https://github.com/swift-web-standards/swift-json-feed-standard", from: "0.1.0")
]Then add the product to your target dependencies:
.target(
name: "YourTarget",
dependencies: [
.product(name: "JSONFeed Types", package: "swift-json-feed-standard")
]
)import JSONFeed
// Create a JSON feed with type-safe structures
let feed = JSONFeed.Feed(
title: "My Blog",
homePageURL: URL(string: "https://example.com")!,
items: [
try! JSONFeed.Item(
id: "1",
url: URL(string: "https://example.com/post1")!,
title: "First Post",
contentHTML: "<p>Hello, world!</p>",
datePublished: Date()
)
]
)
print(feed.title) // "My Blog"
print(feed.items.count) // 1Note: This package provides only the type definitions. For JSON generation and parsing, see swift-json-feed.
- swift-json-feed: JSON feed generation with type-safe convenience APIs and ArrayBuilder support
- swift-rss-standard: Type-safe RSS 2.0 feed type definitions
- swift-rfc-4287: Type-safe Atom feed type definitions (RFC 4287)
- swift-syndication: Unified syndication API supporting RSS, Atom, and JSON Feed with format conversion
This project is licensed under the Apache License 2.0. See LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.