{ "info": { "author": "Clayton Stout", "author_email": "clayfstout@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7", "Topic :: Internet :: Log Analysis", "Topic :: Software Development", "Topic :: Utilities" ], "description": "JSON to JSON diff tool\n======================\n\n|Build Status|\n\nFound a bug? Need a new feature? Want to help out? Check out the\n`Contributor\u2019s guide`_\n\nIntroduction\n------------\n\nA python module for checking equivalence and difference of two JSONs\nwith regex support\n\nThis repository will treat two types of JSON necessary for our purpose:\n\n#. Regular JSON where only data is stored\n\n#. Model JSON which will treat all keys and values as regular\n expressions\n\n - Models will be used for comparing JSON objects to A model for\n equivalence with regex matching\n - As JSON can be in a non-deterministic order, this is harder\n than doing a straight string comparison\n\nThere are four modes of this module\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n#. Regular JSON comparison\n#. JSON to Model comparison\n#. Regular JSON diff\n#. JSON to Model Diff\n\n1. Regular JSON comparison\n--------------------------\n\nThis simply tests whether two files contating json are the same\n\n.. code-block:: bash\n\n ./json_diff.py path/to/file1.json path/to/file2.json\n\nReturns True if equal or False otherwise.\n\n.. code-block:: bash\n\n .json_diff.py path/to/file1.json path/to/json_directory/\n\nReturns the filename of the first match if there is one, or False\notherwise.\n\n2. JSON to Model comparison\n---------------------------\n\nThis mode tests whether a given JSON file matches a model when regular\nexpressions are evaluated.\n\n.. code-block:: bash\n\n ./json_diff.py --mode j2m path/to/pure.json path/to/model.json\n\nReturns True if the JSON and model match, False otherwise.\n\n.. code-block:: bash\n\n ./json_diff.py --mode j2m path/to/pure.json path/to/model_directory\n\nReturns the filename of the first match if there is one, or False\notherwise.\n\n3. Regular JSON diff\n--------------------\n\nThis mode computes a file diff between two JSON files.\n\n*The logic flow of this code is loosely based off of code found in\nhttps://github.com/monsur/jsoncompare*\n\n*Assuming*\n\n\nold.json:\n\n.. code-block:: json\n\n {\n \"accounting\" : [ {\n \"firstName\" : \"John\",\n \"lastName\" : \"Doe\",\n \"age\" : 23\n }, {\n \"firstName\" : \"Mary\",\n \"lastName\" : \"Smith\",\n \"age\" : 31\n } ],\n \"sales\" : [ {\n \"firstName\" : \"Sally\",\n \"lastName\" : \"Green\",\n \"age\" : 27\n }, {\n \"firstName\" : \"Jim\",\n \"lastName\" : \"Galley\",\n \"age\" : 41\n } ]\n }\n\nand new.json:\n\n.. code-block:: json\n\n {\n \"accounting\" : [ {\n \"firstName\" : true,\n \"lastName\" : \"Doe\",\n \"age\" : 23\n }, {\n \"firstName\" : \"Susan\",\n \"lastName\" : \"Smith\",\n \"age\" : 31\n } ],\n \"sales\" : [ {\n \"firstName\" : \"Sally\",\n \"lastName\" : \"Green\",\n \"size\" : 27\n }, {\n \"firstName\" : \"Jim\",\n \"age\" : 41\n } ]\n }\n\nThen\n\nShould produce output like:\n\n.. code:: bash\n\n 2015-03-24 12:59:08,576 - jsondiff - INFO - TypeDifference : accounting[0].firstName - is bool: (True), but was unicode: (John)\n 2015-03-24 12:59:08,576 - jsondiff - INFO - Changed: accounting[1].firstName to Susan from Mary\n 2015-03-24 12:59:08,576 - jsondiff - INFO - +: sales[0].size =27\n 2015-03-24 12:59:08,576 - jsondiff - INFO - -: sales[0].age=27\n 2015-03-24 12:59:08,576 - jsondiff - INFO - -: sales[1].lastName=Galley\n\n4. JSON to Model Diff\n---------------------\n\nThis mode computes a file diff between a JSON file and a model with\nregular expressions.\n\n***Note: at this time, we only support regular expression matching on\nsingleton values (that is values that are NOT a list or dictionary)***\n\n*Assuming*\n\n\nnew.json:\n\n.. code-block:: json\n\n {\n \"accounting\" : [ {\n \"firstName\" : \"John\",\n \"lastName\" : \"Doe\",\n \"age\" : 23\n }, {\n \"firstName\" : \"Mary\",\n \"lastName\" : \"Smith\",\n \"age\" : 31\n } ],\n \"sales\" : [ {\n \"firstName\" : \"Sally\",\n \"lastName\" : \"Green\",\n \"age\" : 27\n }, {\n \"firstName\" : \"Jim\",\n \"lastName\" : \"Galley\",\n \"age\" : 41\n } ]\n }\n\nand model.json:\n\n.. code-block:: json\n\n {\n \"accounting\" : [ {\n \"lastName\" : \"Doe\",\n \"age\" : 23\n }, {\n \"firstName\" : \"Mary\",\n \"lastName\" : \"Smith\",\n \"age\" : \"[0-9]+\"\n } ],\n \"sales\" : [ {\n \"firstName\" : \"Sally\",\n \"lastName\" : \"(.*)\",\n \"age\" : 24\n }, {\n \"firstName\" : \"Jim\",\n \"lastName\" : \"Galley\",\n \"age\" : 41\n } ]\n }\n\nThen\n\n.. code-block:: bash\n\n .json_diff.py -d --mode j2m new.json model.json\n\nShould produce output\n\n.. code-block:: bash\n\n 2015-03-24 12:59:08,576 - jsondiff - INFO - +: accounting[0].firstName=John\n 2015-03-24 12:59:08,576 - jsondiff - INFO - Changed: sales[0].age to 27 from 24\n\nAs you can see we find a match on numbers even though the type is \u2018int\u2019\n(Mary Smith\u2019s age). Also, even though we changed Sally\u2019s age, we were\nstill able to find a match on her entry with a regular expression\nrepresenting her last name.\n\n.. _Contributor\u2019s guide: https://github.com/bazaarvoice/json-regex-difftool/blob/master/CONTRIBUTING.md\n\n.. |Build Status| image:: https://travis-ci.org/bazaarvoice/json-regex-difftool.svg?branch=master\n :target: https://travis-ci.org/bazaarvoice/json-regex-difftool", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bazaarvoice/json-regex-difftool.git", "keywords": "JSON,regular expressions,regex,diff,difftool", "license": "Apache Software License", "maintainer": null, "maintainer_email": null, "name": "json-regex-difftool", "package_url": "https://pypi.org/project/json-regex-difftool/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/json-regex-difftool/", "project_urls": { "Homepage": "https://github.com/bazaarvoice/json-regex-difftool.git" }, "release_url": "https://pypi.org/project/json-regex-difftool/0.2/", "requires_dist": null, "requires_python": null, "summary": "A tool for doing a comparison or difference of JSON documentswith regular expression support", "version": "0.2" }, "last_serial": 1477351, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "2f7a4826b2d792f3797e28cab6791da1", "sha256": "c063c1127ee179d4fe7180317472a485b86f6855ad9d47246f7ab24edd0b5a4b" }, "downloads": -1, "filename": "json-regex-difftool-0.1.tar.gz", "has_sig": false, "md5_digest": "2f7a4826b2d792f3797e28cab6791da1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7309, "upload_time": "2014-12-18T16:41:50", "url": "https://files.pythonhosted.org/packages/af/53/93b5d58a3d660224e840eea540f7f5dbfaa42db45485b81bac247405f1a2/json-regex-difftool-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "8caaddb5d342636a8a8a9c388221554b", "sha256": "7d4703d8ea62b84486dd23689f941da92293939392200fd9ca4f28d1db9ac673" }, "downloads": -1, "filename": "json-regex-difftool-0.2.tar.gz", "has_sig": false, "md5_digest": "8caaddb5d342636a8a8a9c388221554b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8917, "upload_time": "2015-03-25T17:45:44", "url": "https://files.pythonhosted.org/packages/69/1c/88bb4326988c34ea611e01d95d3641909b49af31bedb4f86741fb82bdb41/json-regex-difftool-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8caaddb5d342636a8a8a9c388221554b", "sha256": "7d4703d8ea62b84486dd23689f941da92293939392200fd9ca4f28d1db9ac673" }, "downloads": -1, "filename": "json-regex-difftool-0.2.tar.gz", "has_sig": false, "md5_digest": "8caaddb5d342636a8a8a9c388221554b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8917, "upload_time": "2015-03-25T17:45:44", "url": "https://files.pythonhosted.org/packages/69/1c/88bb4326988c34ea611e01d95d3641909b49af31bedb4f86741fb82bdb41/json-regex-difftool-0.2.tar.gz" } ] }