Skip to content

This is the single-file class definitions which represents the structure of JSON Feed 1.1.

License

Notifications You must be signed in to change notification settings

suconbu/jsonfeed_dataclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

jsonfeed_dataclass

This is the single-file class definitions which represents the structure of JSON Feed 1.1.

Class

  • Feed
    Represents a top-level of the feed.

  • Item
    Represents a each article/entry of feed.

  • Person
    Represents a person information that using in author field.

  • Attachment
    Represents an external resource such as an audio or video.

  • Element
    Base class of Feed, Item and Parson class.
    It has the conversion methods such as to dict/JSON.

Example of use

Sample code:

# sample.py

from jsonfeed import Feed, Item

# Create feed instance
feed = Feed(title="sample1", home_page_url="http://sample.org")

# Add items into the feed
for i in range(0, 100):
    feed.items.append(Item(id=f"item{i}", url=f"http://sample.org/item{i}/"))

# Output the feed as JSON
print(feed.to_json(indent=2))

Run the sample code:

$ ls
jsonfeed.py sample.py

$ ./sample.py
{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "sample1",
  "home_page_url": "http://sample.org",
  "items": [
    {
      "id": "item1",
      "url": "http://sample.org/item1/"
    }
    ...
  ]
}

License

CC0

About

This is the single-file class definitions which represents the structure of JSON Feed 1.1.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages