Support JSON Feed 1.1 authors and language - #224
Merged
Conversation
JSON Feed 1.1 deprecated the singular `author` in favour of an `authors` array, and 1.1 feeds in the wild (daringfireball.net/feeds/json, inessential.com/feed.json) omit `author` entirely, so `author` decoded as nil with nothing to fall back to. - Add `authors` to `JSONFeed` and `JSONFeedItem`, falling back to `authors.first` when the deprecated `author` is absent, so both keys remain usable regardless of the feed version. - Add `language` to `JSONFeed` and `JSONFeedItem`, also new in 1.1. - Set the version to 1.1 when a feed built in code uses either member. - Decode `JSONFeedAuthor.name` as optional; the spec has always listed all of its members as optional, and 1.1 feeds do publish url-only authors. Fixes nmdias#223 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
Looking good! Thank you @alexhumphreys 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #223
JSON Feed 1.1 deprecated the singular author in favour of an authors array. 1.1 feeds in the wild omit author entirely — including daringfireball.net/feeds/json and inessential.com/feed.json, both from people who wrote the spec — so author decoded as nil with nothing to fall back to.
Testing: new feed_v1_1.json fixture covering feed and item authors, both language levels, and a url-only author, with decode, round-trip, and regression tests. The existing 1.0 fixture and tests are untouched and pass. Verified against both feeds above: all 48 Daring Fireball items now resolve an author, previously all nil.
Note: I didn't implement feed->item author inheritance. The spec says a missing item author means the top-level one applies (inessential.com relies on this), but adding it would change behaviour for 1.0 feeds too — happy to include it if you'd prefer.