jsonfeed

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package jsonfeed parses JSON Feed 1.0 and 1.1 documents and adapts them to the canonical feed model.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingRequired = errors.New("missing required field")

ErrMissingRequired reports a member the JSON Feed specification requires. The caller maps it to the exported sentinel it classifies; the wrapping message names the member.

Functions

func Adapt

func Adapt(native *Feed) (*model.Feed, error)

Adapt converts a native JSON Feed to the canonical model.

Types

type Attachment

type Attachment struct {
	URL               string
	MimeType          string
	Title             string
	SizeInBytes       *int64
	DurationInSeconds *int64
}

Attachment represents a JSON Feed attachment.

type Author

type Author struct {
	Name   string
	URL    string
	Avatar string
}

Author represents a JSON Feed author object.

type Feed

type Feed struct {
	Version     string
	Title       string
	HomePageURL string
	FeedURL     string
	Description string
	UserComment string
	NextURL     string
	Icon        string
	Favicon     string
	Author      *Author
	Authors     []Author
	Language    string
	Expired     *bool
	Hubs        []Hub
	Items       []Item

	// Extensions holds the members the document added to the feed object under
	// its own underscore-prefixed names, verbatim and undecoded.
	Extensions map[string]any

	// Warnings lists what the document broke that did not cost it the parse:
	// an item with no content, an item discarded for having no id, an "authors"
	// array holding nothing usable. See the README's leniency policy.
	Warnings warn.List
}

Feed represents the native JSON Feed structure.

type Hub

type Hub struct {
	Type string
	URL  string
}

Hub represents a JSON Feed hub for real-time notifications.

type Item

type Item struct {
	ID            string
	URL           string
	ExternalURL   string
	Title         string
	ContentHTML   string
	ContentText   string
	Summary       string
	Image         string
	BannerImage   string
	DatePublished string
	DateModified  string
	Author        *Author
	Authors       []Author
	Tags          []string
	Language      string
	Attachments   []Attachment

	// Extensions holds the members the document added to this item under its
	// own underscore-prefixed names, verbatim and undecoded.
	Extensions map[string]any
}

Item represents a JSON Feed item.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses JSON Feed documents.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser creates a new JSON Feed parser.

func (*Parser) Parse

func (p *Parser) Parse() (*Feed, error)

Parse parses the JSON Feed from the input stream.

The document as a whole is validated: a feed with no version, no title, no items array, or an unknown version is rejected. A single item is not the document — see [parseItem] — so nothing one item states or fails to state rejects the feed or costs a sibling item.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL