jsonfeed-util


Namejsonfeed-util JSON
Version 1.1.4 PyPI version JSON
download
home_pagehttps://github.com/lukasschwab/jsonfeed
SummaryPython package for parsing and generating JSON feeds.
upload_time2025-01-10 01:51:50
maintainerNone
docs_urlNone
authorLukas Schwab
requires_pythonNone
licenseMIT
keywords json feed jsonfeed
VCS
bugtrack_url
requirements feedparser pytest pdoc pip-audit
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/) [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/lukasschwab/jsonfeed/python-package.yaml?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.to_json())
```

`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 non-meaningful 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": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "json feed jsonfeed",
    "author": "Lukas Schwab",
    "author_email": "lukas.schwab@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/68/e2/fb797764efcaa3977a965c55cc234b568ec6f2f7a8ddd1423668eb83e18e/jsonfeed_util-1.1.4.tar.gz",
    "platform": null,
    "description": "# jsonfeed\n[![PyPI](https://img.shields.io/pypi/v/jsonfeed-util)](https://pypi.org/project/jsonfeed-util/) [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/lukasschwab/jsonfeed/python-package.yaml?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.to_json())\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 non-meaningful 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.4",
    "project_urls": {
        "Homepage": "https://github.com/lukasschwab/jsonfeed"
    },
    "split_keywords": [
        "json",
        "feed",
        "jsonfeed"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1da6877d5bcbb93ef1daf705debf259ad905cce407fa313c1510766c3fa1ebc7",
                "md5": "3c35bd45478ca671e442aeaf6b14a9f5",
                "sha256": "4762fb0e29c9fae15cd42f6153af524bb608dd8af0eecfdd803eedc8f35d7763"
            },
            "downloads": -1,
            "filename": "jsonfeed_util-1.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3c35bd45478ca671e442aeaf6b14a9f5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6348,
            "upload_time": "2025-01-10T01:51:47",
            "upload_time_iso_8601": "2025-01-10T01:51:47.580274Z",
            "url": "https://files.pythonhosted.org/packages/1d/a6/877d5bcbb93ef1daf705debf259ad905cce407fa313c1510766c3fa1ebc7/jsonfeed_util-1.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68e2fb797764efcaa3977a965c55cc234b568ec6f2f7a8ddd1423668eb83e18e",
                "md5": "c11435e83c143616e5c545bf7993bc76",
                "sha256": "ae4ad1bb8a3dad2172939d6b18c4121cce7c1021e3693e669d2c95ddfa04c36f"
            },
            "downloads": -1,
            "filename": "jsonfeed_util-1.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "c11435e83c143616e5c545bf7993bc76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5607,
            "upload_time": "2025-01-10T01:51:50",
            "upload_time_iso_8601": "2025-01-10T01:51:50.981965Z",
            "url": "https://files.pythonhosted.org/packages/68/e2/fb797764efcaa3977a965c55cc234b568ec6f2f7a8ddd1423668eb83e18e/jsonfeed_util-1.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-10 01:51:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lukasschwab",
    "github_project": "jsonfeed",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "feedparser",
            "specs": [
                [
                    "==",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "6.2.2"
                ]
            ]
        },
        {
            "name": "pdoc",
            "specs": [
                [
                    "==",
                    "14.5.1"
                ]
            ]
        },
        {
            "name": "pip-audit",
            "specs": [
                [
                    ">=",
                    "1.1.2"
                ]
            ]
        }
    ],
    "lcname": "jsonfeed-util"
}
        
Elapsed time: 2.40064s