Skip to main content

JSONObjects allows you to declaratively specify how to extract and convert elements from a JSON document.

Project description

jsonobjects allows you to declaratively specify how to extract and convert elements from a JSON document.


We recommend the use of virtualenv and of pip. You can then use pip install -U jsonobjects. You may also have setuptools and thus you can use easy_install -U jsonobjects. Otherwise, you can download the source from GitHub and run python install.


All dependencies are optional.


Example of schema to parse iTunes lookup response for software item:

import json
import requests
import jsonobjects as jo

class iTunesAppSchema(jo.Schema):
    id = jo.IntegerField('trackId')
    url = jo.Field('trackViewUrl')
    name = jo.StringField('trackName')
    currency = jo.StringField()
    price = jo.FloatField(min_value=0.0)
    rating = jo.FloatField('averageUserRating')
    reviews = jo.IntegerField('userRatingCountForCurrentVersion')
    version = jo.StringField()
    publisher_id = jo.IntegerField('artistId')
    publisher_url = jo.Field('artistViewUrl')
    publisher_name = jo.StringField('artistName')
    categories = jo.ListField('genres', child=jo.StringField())
    icon = jo.Field(
        ['artworkUrl512', 'artworkUrl60'], post_process=lambda v: {'url': v})
    screenshots = jo.ListField(
        'screenshotUrls', child=jo.Field(post_process=lambda v: {'url': v}))

parser = iTunesAppSchema('results[0]')

def get_app_details(app_id):
    url = '{}'
    return requests.get(url.format(app_id)).json()

details = get_app_details(880047117)

The code above produces next result:

  "categories": ["Games", "Puzzle", "Action"],
  "currency": "USD",
  "icon": {"url": ""},
  "id": 880047117,
  "name": "Angry Birds 2",
  "price": 0.0,
  "publisher_id": 298910979,
  "publisher_name": "Rovio Entertainment Ltd",
  "publisher_url": "",
  "rating": 4.0,
  "reviews": 4796,
  "screenshots": [
    {"url": ""},
    {"url": ""},
    {"url": ""},
    {"url": ""},
    {"url": ""}
  "url": "",
  "version": "2.2.1"

See for more examples.


Getting the tests running looks like:

# Install dependencies
$ pip install -r requirement.txt
# Run the test suites
$ python


The MIT License (MIT)

Contributed by Maxim Kamenkov

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonobjects-1.0.3.tar.gz (13.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page