jsonfeed-util


Namejsonfeed-util JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/lukasschwab/jsonfeed
SummaryPython package for parsing and generating JSON feeds.
upload_time2024-01-13 21:14:15
maintainer
docs_urlNone
authorLukas Schwab
requires_python
licenseMIT
keywords json feed jsonfeed
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jsonfeed
[![PyPI](https://img.shields.io/pypi/v/jsonfeed-util)](https://pypi.org/project/jsonfeed-util/) [![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/lukasschwab/jsonfeed/python-package.yml?branch=master)](https://github.com/lukasschwab/jsonfeed/actions?query=branch%3Amaster) [![Full package documentation](https://img.shields.io/badge/docs-hosted-brightgreen)](https://lukasschwab.me/jsonfeed/index.html)

`jsonfeed` is a Python package for parsing and constructing [JSON Feeds](https://jsonfeed.org/version/1.1). It explicitly supports JSON Feed Version 1.1.

## Usage

This package's constructor arguments and class variables exactly match the field names defined in the JSON feed spec. I hope that the code is clear enough that the spec can be its granular documentation.

### Installation

Install this package with `pip`:

```shell
$ pip install jsonfeed-util
```

In your Python code, include the line

```python
import jsonfeed
```

### Parsing a JSON feed

```python
import jsonfeed as jf
import requests

# Requesting a valid JSON feed!
r = requests.get('https://arxiv-feeds.appspot.com/json/test')
# Parse from raw text...
feed_from_text = jf.Feed.parse_string(r.text)
# ...or parse JSON separately.
r_json = r.json()
feed_from_json = jf.Feed.parse(r_json)
```

### Constructing a JSON feed

```python
import jsonfeed as jf

me = jf.Author(
  name="Lukas Schwab",
  url="https://github.com/lukasschwab"
)
feed = jf.Feed("My Feed Title", authors=[me])
item = jf.Item("some_item_id")
feed.items.append(item)

print(feed.toJSON())
```

`jsonfeed` exposes constructors for five classes of JSON feed objects:

+ `Feed`
+ `Author`
+ `Hub`
+ `Item`
+ `Attachment`

Note, `jsonfeed` is designed to be minimally restrictive. It does not require fields that are not required in the JSON Feed spec. This means it's possible to construct nonmeaningful JSON feeds (e.g. with this valid `Author` object: `{}`).

### Examples

+ [`arxiv-feeds`](https://github.com/lukasschwab/arxiv-feeds): converts Atom to JSON feeds.
+ [`jsonfeed-wrapper`](https://github.com/lukasschwab/jsonfeed-wrapper): converts scraped HTML to JSON feeds.
+ [`pandoc-blog`](https://github.com/lukasschwab/pandoc-blog): generates a JSON feed for a static site.

## Deprecations

See [the spec](https://jsonfeed.org/) for an overview of deprecated JSON Feed fields. This project (especially the `converters` and the parsing functions) will stay backwards-compatible when possible, but using deprecated fields when constructing feeds is discouraged.

### JSON Feed 1.1

+ `Feed.author` is deprecated. Use `Feed.authors`.
+ `Item.author` is deprecated. Use `Item.authors`.

## Notes

+ Dictionaries maintain insertion order as of Python 3.6. `jsonfeed` takes advantage of this to retain the order suggested in the JSON Feed spec (namely, that `version` appear at the top of the JSON object). This order may not be enforced in earlier versions of Python, but out-of-order JSON Feeds are not invalid.

+ I made a conscious decision to shoot for code that's readable––vis à vis the JSON Feed spec––rather than code that's minimal or performant. Additionally, I opted to avoid dependencies outside of the standard library. Hopefully this makes for easy maintenance.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lukasschwab/jsonfeed",
    "name": "jsonfeed-util",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "json feed jsonfeed",
    "author": "Lukas Schwab",
    "author_email": "lukas.schwab@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/90/eb/9c9b6f64d74a85aa4236863766ee4f4f82447d7f0618eed0cc66317d0297/jsonfeed-util-1.1.2.tar.gz",
    "platform": null,
    "description": "# jsonfeed\n[![PyPI](https://img.shields.io/pypi/v/jsonfeed-util)](https://pypi.org/project/jsonfeed-util/) [![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/lukasschwab/jsonfeed/python-package.yml?branch=master)](https://github.com/lukasschwab/jsonfeed/actions?query=branch%3Amaster) [![Full package documentation](https://img.shields.io/badge/docs-hosted-brightgreen)](https://lukasschwab.me/jsonfeed/index.html)\n\n`jsonfeed` is a Python package for parsing and constructing [JSON Feeds](https://jsonfeed.org/version/1.1). It explicitly supports JSON Feed Version 1.1.\n\n## Usage\n\nThis package's constructor arguments and class variables exactly match the field names defined in the JSON feed spec. I hope that the code is clear enough that the spec can be its granular documentation.\n\n### Installation\n\nInstall this package with `pip`:\n\n```shell\n$ pip install jsonfeed-util\n```\n\nIn your Python code, include the line\n\n```python\nimport jsonfeed\n```\n\n### Parsing a JSON feed\n\n```python\nimport jsonfeed as jf\nimport requests\n\n# Requesting a valid JSON feed!\nr = requests.get('https://arxiv-feeds.appspot.com/json/test')\n# Parse from raw text...\nfeed_from_text = jf.Feed.parse_string(r.text)\n# ...or parse JSON separately.\nr_json = r.json()\nfeed_from_json = jf.Feed.parse(r_json)\n```\n\n### Constructing a JSON feed\n\n```python\nimport jsonfeed as jf\n\nme = jf.Author(\n  name=\"Lukas Schwab\",\n  url=\"https://github.com/lukasschwab\"\n)\nfeed = jf.Feed(\"My Feed Title\", authors=[me])\nitem = jf.Item(\"some_item_id\")\nfeed.items.append(item)\n\nprint(feed.toJSON())\n```\n\n`jsonfeed` exposes constructors for five classes of JSON feed objects:\n\n+ `Feed`\n+ `Author`\n+ `Hub`\n+ `Item`\n+ `Attachment`\n\nNote, `jsonfeed` is designed to be minimally restrictive. It does not require fields that are not required in the JSON Feed spec. This means it's possible to construct nonmeaningful JSON feeds (e.g. with this valid `Author` object: `{}`).\n\n### Examples\n\n+ [`arxiv-feeds`](https://github.com/lukasschwab/arxiv-feeds): converts Atom to JSON feeds.\n+ [`jsonfeed-wrapper`](https://github.com/lukasschwab/jsonfeed-wrapper): converts scraped HTML to JSON feeds.\n+ [`pandoc-blog`](https://github.com/lukasschwab/pandoc-blog): generates a JSON feed for a static site.\n\n## Deprecations\n\nSee [the spec](https://jsonfeed.org/) for an overview of deprecated JSON Feed fields. This project (especially the `converters` and the parsing functions) will stay backwards-compatible when possible, but using deprecated fields when constructing feeds is discouraged.\n\n### JSON Feed 1.1\n\n+ `Feed.author` is deprecated. Use `Feed.authors`.\n+ `Item.author` is deprecated. Use `Item.authors`.\n\n## Notes\n\n+ Dictionaries maintain insertion order as of Python 3.6. `jsonfeed` takes advantage of this to retain the order suggested in the JSON Feed spec (namely, that `version` appear at the top of the JSON object). This order may not be enforced in earlier versions of Python, but out-of-order JSON Feeds are not invalid.\n\n+ I made a conscious decision to shoot for code that's readable\u2013\u2013vis \u00e0 vis the JSON Feed spec\u2013\u2013rather than code that's minimal or performant. Additionally, I opted to avoid dependencies outside of the standard library. Hopefully this makes for easy maintenance.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package for parsing and generating JSON feeds.",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://github.com/lukasschwab/jsonfeed"
    },
    "split_keywords": [
        "json",
        "feed",
        "jsonfeed"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90eb9c9b6f64d74a85aa4236863766ee4f4f82447d7f0618eed0cc66317d0297",
                "md5": "dd0c049d0231dbd0d731198e0037368c",
                "sha256": "f73e8699543c9e03d35517c72cc38a0952c25dc6bb239b89a0c3b7a206cdac5c"
            },
            "downloads": -1,
            "filename": "jsonfeed-util-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "dd0c049d0231dbd0d731198e0037368c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5302,
            "upload_time": "2024-01-13T21:14:15",
            "upload_time_iso_8601": "2024-01-13T21:14:15.655796Z",
            "url": "https://files.pythonhosted.org/packages/90/eb/9c9b6f64d74a85aa4236863766ee4f4f82447d7f0618eed0cc66317d0297/jsonfeed-util-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-13 21:14:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lukasschwab",
    "github_project": "jsonfeed",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "jsonfeed-util"
}
        
Elapsed time: 0.16183s