{ "info": { "author": "ScrapingHub", "author_email": "info@scrapinghub.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "===============================\r\nFlatson\r\n===============================\r\n\r\n.. image:: https://img.shields.io/travis/scrapinghub/flatson.svg\r\n :target: https://travis-ci.org/scrapinghub/flatson\r\n\r\n.. image:: https://img.shields.io/pypi/v/flatson.svg\r\n :target: https://pypi.python.org/pypi/flatson\r\n\r\n\r\nA tool to flatten JSON-like objects, allowing to configure via an annotated JSON schema\r\n\r\n* Free software: BSD license\r\n* Documentation: https://flatson.readthedocs.org.\r\n\r\nFeatures\r\n--------\r\n\r\n* Flattens Python dictionaries using a JSON schema\r\n* Supports per-field configuration via the schema\r\n\r\nUsage::\r\n\r\n >>> from flatson import Flatson\r\n >>> schema = {\r\n \"$schema\": \"http://json-schema.org/draft-04/schema\",\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"name\": {\"type\": \"string\"},\r\n \"age\": {\"type\": \"number\"},\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\"city\": {\"type\": \"string\"}, \"street\": {\"type\": \"string\"}}\r\n },\r\n \"skills\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}\r\n }\r\n }\r\n >>> sample = {\r\n \"name\": \"Claudio\", \"age\": 42,\r\n \"address\": {\"city\": \"Paris\", \"street\": \"Rue de Sevres\"},\r\n \"skills\": [\"hacking\", \"soccer\"]}\r\n >>> f = Flatson(schema)\r\n >>> f.fieldnames\r\n ['address.city', 'address.street', 'age', 'name', 'skills']\r\n >>> f.flatten(sample)\r\n ['Paris', 'Rue de Sevres', 42, 'Claudio', '[\"hacking\",\"soccer\"]']\r\n\r\nYou can get a dict with the field names order preserved::\r\n\r\n >>> f.flatten_dict(sample)\r\n OrderedDict([('address.city', 'Paris'), ('address.street', 'Rue de Sevres'), ('age', 42), ('name', 'Claudio'), ('skills', '[\"hacking\",\"soccer\"]')])\r\n\r\nYou can also configure array serialization behavior through the schema (default JSON)::\r\n\r\n >>> schema = {\r\n \"$schema\": \"http://json-schema.org/draft-04/schema\",\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"name\": {\"type\": \"string\"},\r\n \"skills\": {\r\n \"type\": \"array\",\r\n \"items\": {\"type\": \"string\"},\r\n \"flatson_serialize\": {\"method\": \"join_values\"},\r\n }\r\n }\r\n }\r\n >>> f = Flatson(schema)\r\n >>> f.flatten({\"name\": \"Salazar\", \"skills\": [\"hacking\", \"socker\", \"partying\"]})\r\n ['Salazar', 'hacking,socker,partying']\r\n\r\n\r\n\r\n\r\n\r\nHistory\r\n-------\r\n\r\n0.1.0 (2015-06-02)\r\n---------------------\r\n\r\n* First release on PyPI.", "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/scrapinghub/flatson", "keywords": "flatson", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "flatson", "package_url": "https://pypi.org/project/flatson/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/flatson/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/scrapinghub/flatson" }, "release_url": "https://pypi.org/project/flatson/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Tool to flatten stream of JSON-like objects, configured via schema", "version": "0.1.0" }, "last_serial": 1739213, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5f16b2107aef81b2e401f416814e13f6", "sha256": "561d8401cff143e4977f02bc2812d890e88aec99c4651eac63da69af1ef07b45" }, "downloads": -1, "filename": "flatson-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5f16b2107aef81b2e401f416814e13f6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5838, "upload_time": "2015-09-25T22:16:18", "url": "https://files.pythonhosted.org/packages/29/65/5797c3cd3ab571c889817d28cb11c4c5ba739f7c1c0e46c9d710943bd87a/flatson-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5a9e6a2ffb3e964419fcbcc49636333b", "sha256": "3e63836d7b7f403ef56f43e62478bf322c77e9510a82a6c878e43c11b163cb8a" }, "downloads": -1, "filename": "flatson-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5a9e6a2ffb3e964419fcbcc49636333b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15581, "upload_time": "2015-09-25T22:16:23", "url": "https://files.pythonhosted.org/packages/2d/ad/1448b5223740acbe699a2d9740c94cd95fbee69593b4d65a49663cfe7ce5/flatson-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5f16b2107aef81b2e401f416814e13f6", "sha256": "561d8401cff143e4977f02bc2812d890e88aec99c4651eac63da69af1ef07b45" }, "downloads": -1, "filename": "flatson-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5f16b2107aef81b2e401f416814e13f6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5838, "upload_time": "2015-09-25T22:16:18", "url": "https://files.pythonhosted.org/packages/29/65/5797c3cd3ab571c889817d28cb11c4c5ba739f7c1c0e46c9d710943bd87a/flatson-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5a9e6a2ffb3e964419fcbcc49636333b", "sha256": "3e63836d7b7f403ef56f43e62478bf322c77e9510a82a6c878e43c11b163cb8a" }, "downloads": -1, "filename": "flatson-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5a9e6a2ffb3e964419fcbcc49636333b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15581, "upload_time": "2015-09-25T22:16:23", "url": "https://files.pythonhosted.org/packages/2d/ad/1448b5223740acbe699a2d9740c94cd95fbee69593b4d65a49663cfe7ce5/flatson-0.1.0.tar.gz" } ] }