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.

Files for jsonobjects, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size jsonobjects-1.0.3.tar.gz (13.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page