{ "info": { "author": "Gleb Karpushkin", "author_email": "rugleb@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "## The JSON Comparison package\n\n[![Build Status](https://travis-ci.com/rugleb/jsoncompare.svg?branch=master)](https://travis-ci.com/rugleb/jsoncompare)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nThis package is designed to compare two objects with a JSON-like structure and data types.\n\n### Installation\n\n```\npip install jsoncomparison\n```\n\n### Usage\n\nFirst you need to define two variables: expected & actual.\nThink of them as the same variables that you use in unittests.\n\nExpected - the original data object, that you want to see.\nActual - the given data object.\n\nThen we will transfer these objects to check and identify the difference between them:\n\n```python\nfrom jsoncomparison import Compare\n\n\nexpected = {\n 'project': {\n 'name': 'jsoncomparison',\n 'version': '0.1',\n 'license': 'MIT',\n 'language': {\n 'name': 'python',\n 'versions': [\n 3.5,\n 3.6\n ]\n }\n },\n 'os': 'linux'\n}\n\nactual = {\n 'project': {\n 'name': 'jsoncomparison',\n 'version': 0.1,\n 'license': 'Apache 2.0',\n 'language': {\n 'name': 'python',\n 'versions': [\n 3.6\n ]\n }\n }\n}\n\ndiff = Compare().check(expected, actual)\nassert diff != {}\n```\n\nThe `check` method returns a dictionary of differences between `expected` and `actual` objects, and report about it.\n\nDiff output:\n```json\n{\n \"project\": {\n \"version\": {\n \"_message\": \"Types not equal. Expected: , received: \",\n \"_expected\": \"str\",\n \"_received\": \"float\"\n },\n \"license\": {\n \"_message\": \"Values not equal. Expected: , received: \",\n \"_expected\": \"MIT\",\n \"_received\": \"Apache 2.0\"\n },\n \"language\": {\n \"versions\": {\n \"_length\": {\n \"_message\": \"Lengths not equal. Expected <2>, received: <1>\",\n \"_expected\": 2,\n \"_received\": 1\n },\n \"_content\": {\n \"0\": {\n \"_message\": \"Value not found. Expected <3.5>\",\n \"_expected\": 3.5,\n \"_received\": null\n }\n }\n }\n }\n },\n \"os\": {\n \"_message\": \"Key does not exists. Expected: \",\n \"_expected\": \"os\",\n \"_received\": null\n }\n}\n```\n\nTo check if the objects are the same, just call:\n\n```python\ndiff = Compare().check(expected, actual)\nself.assertEqual(diff, {})\n```\n\n### Configuration\n\nYou can define your configuration file and transfer it to Compare class constructor. \nBut first make sure that the structure of your configuration file is similar to [this](https://github.com/rugleb/jsoncomparison/blob/master/jsoncomparison/data/config.json).\n\nExample:\n\n```python\nimport json\nfrom jsoncomparison import Compare\n\n\nwith open('config', 'r') as fp:\n config = json.load(fp)\n\ncmp = Compare(config)\n```\n\n### Output\n\nBy default, the configuration file does not allow printing the comparison result to the console, but at the same time writes the results to a file.\nThese settings can be changed in your configuration file:\n\n```json\n{ \n \"output\": {\n \"console\": true,\n \"file\": {\n \"name\": \"my-output-file.json\",\n \"indent\": 4\n }\n }\n}\n```\n\n### Ignore rules\n\nWhat if you do not want to compare some values and keys of objects from your JSON's? \nIn this case, you can define exception rules and pass them to the class constructor.\n\nLet's go back to the example above:\n\n```python\nfrom jsoncomparison import Compare\n\n\nexpected = {\n # ...\n}\n\nactual = {\n # ...\n}\n\nrules = {\n 'project': {\n 'version': '*',\n 'license': '*',\n 'language': {\n 'versions': {\n '_values': [\n 3.5\n ]\n }\n }\n },\n 'os': '*',\n}\n\ndiff = Compare(rules=rules).check(expected, actual)\nassert diff == {}\n```\n\nNow that we have added exceptions to the missing values,\nthe comparison test has been successfully passed!\n\n### Links\n\nYou can see a more complex comparison example that I used to test the correct operation of an application: \n[link](https://github.com/rugleb/jsoncomparison/blob/d674b32c80d5dc1114ca109c4b4c75add53c5de8/tests/test_compare.py#L84).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rugleb/jsoncomparison", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "jsoncomparison", "package_url": "https://pypi.org/project/jsoncomparison/", "platform": "", "project_url": "https://pypi.org/project/jsoncomparison/", "project_urls": { "Homepage": "https://github.com/rugleb/jsoncomparison" }, "release_url": "https://pypi.org/project/jsoncomparison/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "JSON comparator", "version": "0.1.1" }, "last_serial": 4369830, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "340bb1e8209f065a8ca7f3c666a96690", "sha256": "dc31050015320f2d4d3d5cb5e623c59a41828882a26decbec667b86de36c14a9" }, "downloads": -1, "filename": "jsoncomparison-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "340bb1e8209f065a8ca7f3c666a96690", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5884, "upload_time": "2018-10-12T10:14:38", "url": "https://files.pythonhosted.org/packages/9e/7d/99e8535c96121ad870805955c148e95f7fa393c16ab5a033102750795b62/jsoncomparison-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3cb51d483bba8983c618eb7fb438fcc5", "sha256": "b100159fce56ef4c1367f66d53bc28251863851629ecbc996e9bc798f8c1d400" }, "downloads": -1, "filename": "jsoncomparison-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3cb51d483bba8983c618eb7fb438fcc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3331, "upload_time": "2018-10-12T10:14:40", "url": "https://files.pythonhosted.org/packages/bd/6e/6b1a500ae48a1e15cff2a8efd8c2e5e776c09ae2ec3e05432a77e9d6ca14/jsoncomparison-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "d7d7a5b9a5afcd03b2aefff47c1497bd", "sha256": "af51c5bdf73ac193493a32b70e9f9d689fe8dcf368cbd6e6eadffd2635004b0d" }, "downloads": -1, "filename": "jsoncomparison-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d7d7a5b9a5afcd03b2aefff47c1497bd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5887, "upload_time": "2018-10-12T10:21:17", "url": "https://files.pythonhosted.org/packages/de/89/122e385114155a36fa60a4d4a9640fae61c9261c1e8c7fe60a8bec59faa4/jsoncomparison-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ada6d66246cec1235bcbfcda2b0c4ae9", "sha256": "b95b0295c7e51b410dac34a82bc68b78c60189e38b0c00cbfd91c9bf0fbfb621" }, "downloads": -1, "filename": "jsoncomparison-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ada6d66246cec1235bcbfcda2b0c4ae9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3335, "upload_time": "2018-10-12T10:21:18", "url": "https://files.pythonhosted.org/packages/d1/5d/4a7ac3bf183557a86ced7ce0869e4448a475d1d0ecd566e907ae9a84047d/jsoncomparison-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "caf8f3af960a619f67ae0f3a40d1b7a1", "sha256": "3d886dd6d96508875a60d93f655e4331fd4b0cfb8d7be29c9d330daeec45c8aa" }, "downloads": -1, "filename": "jsoncomparison-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "caf8f3af960a619f67ae0f3a40d1b7a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5887, "upload_time": "2018-10-12T10:26:11", "url": "https://files.pythonhosted.org/packages/64/7d/8694a97b3aaf55b5b00f86844cd11342708c19530be284330d3c1cc02a96/jsoncomparison-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2b257588ffe488d31613383656d82e2f", "sha256": "118097748816f6758654317957517e52b5562ca65b9ee3384fe687fc77e3966b" }, "downloads": -1, "filename": "jsoncomparison-0.0.3.tar.gz", "has_sig": false, "md5_digest": "2b257588ffe488d31613383656d82e2f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3333, "upload_time": "2018-10-12T10:26:12", "url": "https://files.pythonhosted.org/packages/67/26/fa162c53bdf8fe664051b92759911592812cc0416c1d79e3def9b2566480/jsoncomparison-0.0.3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "5853a7e485680e3235f1635f3bbbd2b3", "sha256": "b507b927dc3969c7d96e536607314442e5ea50ada4fe7c8ccff8023e7983f330" }, "downloads": -1, "filename": "jsoncomparison-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5853a7e485680e3235f1635f3bbbd2b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7614, "upload_time": "2018-10-12T10:39:45", "url": "https://files.pythonhosted.org/packages/43/a2/0ceba086bffa02cc131cb935a38a6e8304878548c64f6924a69c31d04ed8/jsoncomparison-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31271182c175a4985141b474ec6de61f", "sha256": "89fa2c5be9f81ca64f673067df36004ff2f5f1adb9294148db74101635b833f3" }, "downloads": -1, "filename": "jsoncomparison-0.1.0.tar.gz", "has_sig": false, "md5_digest": "31271182c175a4985141b474ec6de61f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4423, "upload_time": "2018-10-12T10:39:46", "url": "https://files.pythonhosted.org/packages/75/db/576c28a25277c780153b3f3af4899c8ddecf11b052500e8d58caa7f411af/jsoncomparison-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a6cfc8ec0c38253d3ef66cac6db5f73b", "sha256": "8c8abbdf0d8cbc4c9ff0864c7975b9cf3d5eb06c650c68109a1ac08ca4443484" }, "downloads": -1, "filename": "jsoncomparison-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a6cfc8ec0c38253d3ef66cac6db5f73b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9004, "upload_time": "2018-10-12T19:08:20", "url": "https://files.pythonhosted.org/packages/6a/2c/0e131d06bcafc8e39fa308a1f4522b523ab14ca5fdca399597378c6fa21c/jsoncomparison-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "57743e9b3fd4003d1f9fdc019d7a22bf", "sha256": "15c1c8ab69a940a0722bf663e8596dbe52859f9b8ee905930d18020d481531a9" }, "downloads": -1, "filename": "jsoncomparison-0.1.1.tar.gz", "has_sig": false, "md5_digest": "57743e9b3fd4003d1f9fdc019d7a22bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6154, "upload_time": "2018-10-12T19:08:21", "url": "https://files.pythonhosted.org/packages/db/31/542344870d8a49d164fab072618bfb6975f55ab882afe9fb8ddd8979981f/jsoncomparison-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a6cfc8ec0c38253d3ef66cac6db5f73b", "sha256": "8c8abbdf0d8cbc4c9ff0864c7975b9cf3d5eb06c650c68109a1ac08ca4443484" }, "downloads": -1, "filename": "jsoncomparison-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a6cfc8ec0c38253d3ef66cac6db5f73b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9004, "upload_time": "2018-10-12T19:08:20", "url": "https://files.pythonhosted.org/packages/6a/2c/0e131d06bcafc8e39fa308a1f4522b523ab14ca5fdca399597378c6fa21c/jsoncomparison-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "57743e9b3fd4003d1f9fdc019d7a22bf", "sha256": "15c1c8ab69a940a0722bf663e8596dbe52859f9b8ee905930d18020d481531a9" }, "downloads": -1, "filename": "jsoncomparison-0.1.1.tar.gz", "has_sig": false, "md5_digest": "57743e9b3fd4003d1f9fdc019d7a22bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6154, "upload_time": "2018-10-12T19:08:21", "url": "https://files.pythonhosted.org/packages/db/31/542344870d8a49d164fab072618bfb6975f55ab882afe9fb8ddd8979981f/jsoncomparison-0.1.1.tar.gz" } ] }