{ "info": { "author": "Imran Ghory", "author_email": "imranghory@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "pson\n====\n\nPython library to make querying JSON-like structures easy!\n\nWith the explosion of APIs returning JSON the use of JSON like structures (i.e what you get if you take JSON and run it through JSON.loads()) querying these types of structures is a common need.\n\nMost people either manually traverse the structures or write their own querying logic, this library aims to solve that need by providing a general purpose querying utils. It uses the dot notation to traverse structures in a similar fashion to document databases such as MongoDB.\n\nExamples\n--------\n\nTo demonstrate by example with the following JSON:\n\n.. code-block:: js\n\n json = {\n 'header' : {'title' : 'Hello World', \n 'year' : 2014}, \n 'body' : { 'translations' : [\n {'language' : 'french', 'translation' : 'bonjour'}, \n {'language' : 'german', 'translation' : 'guten tag'}\n ] \n }\n }\n \nTraditional (pre-pson) approach:\n\n.. code-block:: pycon\n\n >>> json['header']['title']\n 'Hello World'\n\nNew pson approach:\n \n.. code-block:: pycon\n\n >>> from pson import pathquery as pq\n\n >>> pq(json, 'header.title')\n 'Hello World'\n \nSome more pson examples:\n\n.. code-block:: pycon\n\n >>> from pson import pathquery as pq\n\n >>> pq(json, 'header.title')\n 'Hello World'\n \n # as you'd expect it can return sub-structures \n >>> pq(json, 'body')\n {'translations': [{'translation': 'bonjour', 'language': 'french'}, {'translation': 'guten tag', 'language': 'german'}]}\n\n # and arrays\n >>> pq(json, 'body.translations')\n [{'translation': 'bonjour', 'language': 'french'}, {'translation': 'guten tag', 'language': 'german'}]\n \n # you can query into arrays using numerical indicies \n >>> pq(json, 'body.translations.0.language')\n 'french'\n\n # you can also not specify an index and get back an array where the rest of the query \n # is applied to every element in the array\n >>> pq(json, 'body.translations.language')\n ['french', 'german']\n\n \nHow does it handle missing values ?\n\n.. code-block:: pycon\n\n >>> from pson import pathquery as pq\n \n # by default it returns None rather than throwing an exception\n >>> pq(json, 'header.author')\n None\n \n # you can over-ride what it returns though\n >>> pq(json, 'header.author', missing=\"Unknown\")\n 'Unknown'\n \n # which is useful for situations like where you're building strings and don't want to deal\n # with lots of KeyError exceptions\n >>> pq(json, 'header.title') + ' by ' + pq(json, 'header.author', missing=\"Unknown\")\n 'Hello World by Unknown'\n \n \n\nInstallation\n------------\nTBD\n\nAuthors\n------------\n\nBuilt by Imran Ghory (@imranghory). Released under the MIT Licence. Contributions welcome via Github.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/imranghory/pson", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "pson", "package_url": "https://pypi.org/project/pson/", "platform": "any", "project_url": "https://pypi.org/project/pson/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/imranghory/pson" }, "release_url": "https://pypi.org/project/pson/0.5.1/", "requires_dist": null, "requires_python": null, "summary": "Easy querying for JSON like structures", "version": "0.5.1" }, "last_serial": 983334, "releases": { "0.5.1": [ { "comment_text": "", "digests": { "md5": "e45b08652184d2b6048860a844f4586f", "sha256": "5b15c2f49d65c390dbab1123d3ec495f47ae0c091e7595b56cb95729c44ba757" }, "downloads": -1, "filename": "pson-0.5.1.tar.gz", "has_sig": false, "md5_digest": "e45b08652184d2b6048860a844f4586f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4828, "upload_time": "2014-01-27T20:15:55", "url": "https://files.pythonhosted.org/packages/0e/96/4aa51228b789fd69654cd51a48a9bdf3bf38d1271899dd8ff347afb7b2f7/pson-0.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e45b08652184d2b6048860a844f4586f", "sha256": "5b15c2f49d65c390dbab1123d3ec495f47ae0c091e7595b56cb95729c44ba757" }, "downloads": -1, "filename": "pson-0.5.1.tar.gz", "has_sig": false, "md5_digest": "e45b08652184d2b6048860a844f4586f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4828, "upload_time": "2014-01-27T20:15:55", "url": "https://files.pythonhosted.org/packages/0e/96/4aa51228b789fd69654cd51a48a9bdf3bf38d1271899dd8ff347afb7b2f7/pson-0.5.1.tar.gz" } ] }