{ "info": { "author": "John Murray", "author_email": "me@johnmurray.io", "bugtrack_url": null, "classifiers": [], "description": "json-inspect\n============\n\n|PyPI version| |PyPI license|\n\nA command-line tool for inspecting and working with JSON files. Current\nsub-commands supported include\n\n**Table of Contents**\n\n- `Installation <#installation>`__\n- `Sub-Commands <#sub-commands>`__\n- `histo <#histo>`__\n- `ext <#ext>`__\n- `keys <#keys>`__\n- `Planned Improvements <#planned-improvements>`__\n\nInstallation\n------------\n\nYou an simply install with the normal method for Python utils, such as\n\n.. code:: sh\n\n pip install json-inspect\n\nSub-Commands\n------------\n\nEach sub-command has it's own help file and options and serves different\npurposes. Please be sure to read the docs for each command as it may not\nwork like the others. To see the most up-to-date documentation on all\navailable sub-commands, run the utility with the ``-h`` options without\nproviding a sub-command.\n\n.. code:: text\n\n $ json-inspect -h\n usage: json-inspect [-h] [-v] [-f FILE] {histo,ext,keys,validate,format} ...\n\n Utility for inspecting JSON files/input\n\n positional arguments:\n {histo,ext,keys,validate,format}\n histo Create histograms from JSON values\n ext Extract values from JSON\n keys Lists keys in a JSON document\n validate Validate text input as JSON (coming soon maybe)\n format Nicely format JSON input (coming soon maybe)\n\n optional arguments:\n -h, --help show this help message and exit\n -v, --version show program's version number and exit\n -f FILE, --file FILE JSON file to read in. If not provided STDIN will be\n used\n\nNote that there are some global options. The main thing here is that\nsome sort of JSON input is required for this utility to work. This is\ndefined with the global ``-f`` option, or by providing input via\n``STDIN``.\n\nhisto\n~~~~~\n\nIf you are processing a large number of JSON objects/arrays, then it may\nbe useful to know what fields are present, what values they contain, and\nthe frequency of both. Starting off with the help file\n\n.. code:: text\n\n usage: json-inspect histo [-h] [-p PREFIX] [-c] paths [paths ...]\n\n Generate a histogram based on values found using a JSON search expression\n\n positional arguments:\n paths search paths to create histograms for, prefixed with\n optional value from the --prefix option\n\n optional arguments:\n -h, --help show this help message and exit\n -p PREFIX, --prefix PREFIX\n String to prefix all search-paths with\n -c, --conflate Conflate non-empty responses to the same value\n\n- The ``-p`` option will allow you to prefix all of your search paths.\n This is useful if you are performing multiple searches that have a\n common prefix for deeply nested JSON searches.\n- The ``-c`` option will conflate your histogram to two values,\n ``__none__`` and ``__some__``. The first meaning that no key/value\n was found for a given lookup in your search path and the latter\n meaning that *a* value was found. This is useful if you only care\n about the frequency of presence.\n\nA search path is a dot-delimited expression used for traversing JSON\nobjects. An example to get us started is\n\n.. code:: text\n\n [].*.user.demographic.regions.[].name\n\nTo start, note that search expressions contain 3 types of tokens\n\n- ``[]`` - indicates an array. Each item in the array is collected and\n will be processed by the next token\n- ``*`` - indicates an object in which all fields should be collected\n and will be processed by the next token\n- ``TOKEN`` - a field-value of an object. It's value will be collected\n and processed by the next token\n\nFor our example above, it would be satisfied by the following JSON\ndocument\n\n.. code:: json\n\n [\n {\n \"facebook\": {\n \"user\": {\n \"demographic\": {\n \"regions\": [ {\"name\": \"US\"}, {\"name\": \"Kentucky\"}, {\"name\": \"Louisville\"} ]\n }\n }\n },\n \"google\": {\n \"user\": {\n \"demographic\": {\n \"regions\": [ {\"name\": \"US\"}, {\"name\": \"Kentucky\"}, {\"name\": \"Highland Heights\"} ]\n }\n }\n }\n },\n {\n \"twitter\": {\n \"user\": {\n \"demographic\": {\n \"regions\": [ {\"name\": \"UK\"}, {\"name\": \"Wales\"} ]\n }\n }\n }\n }\n ]\n\nRunning the ``histo`` sub-command, we would get output such as\n\n.. code:: sh\n\n cat test.json | json-inspect histo '[].*.user.demographic.regions.[].name'\n\n [].*.user.demographic.regions.[].name:\n Highland Heig | ######################### | (1)\n US | ################################################## | (2)\n Louisville | ######################### | (1)\n Kentucky | ################################################## | (2)\n UK | ######################### | (1)\n Wales | ######################### | (1)\n\nThe bar-chart represents the number found relative to the max found with\na total count of finds per-element in the rightmost column.\n\next\n~~~\n\nThe ``ext``, extraction command, is used for pulling data out of JSON\nfiles. It supports the same prefix and search expressions as ``histo``\nalong with a few other options for value output.\n\n::\n\n $ json-inspect ext -h\n usage: json-inspect ext [-h] [-p PREFIX] [-d DELIM] [-F] paths [paths ...]\n\n Extract values from JSON using a JSON search expression\n\n positional arguments:\n paths search paths to return values for\n\n optional arguments:\n -h, --help show this help message and exit\n -p PREFIX, --prefix PREFIX\n String to prefix all search-paths with\n -d DELIM, --delimiter DELIM\n String to delimit all results by\n -F, --flatten Flatten array and object values. For objects, only the\n values (not the keys) are retained in the falttened\n values\n\nUsing the same input test JSON file from the ``histo`` command, we can\nsee an example of output\n\n::\n\n $ cat test.json | json-inspect ext \"[].*.user.demographic.regions.[].*\"\n Louisville,Kentucky,US,Highland Heights,Kentucky,US,Wales,UK\n\n $ cat test.json | json-inspect ext -d '|' \"[].*.user.demographic.regions.[].*\"\n Louisville|Kentucky|US|Highland Heights|Kentucky|US|Wales|UK\n\nkeys\n~~~~\n\nThe ``keys`` command is used for listing alls keys found within a JSON\ndocument. Flags can be provided to filter which keys are extracted.\n\n::\n\n $ json-inspect keys -h\n usage: json-inspect keys [-h] [-n] [-o] [-p] [-e]\n\n List all keys within the JSON document using a period-delimited notation\n similar to search-paths\n\n optional arguments:\n -h, --help show this help message and exit\n -n, --exclude-null Exclude keys that contain a null value\n -o, --exclude-empty-objects\n Exclude keys that contain an empty object\n -p, --exclude-empty-primitives\n Exclude keys that contain an empty primitive value\n (zero and empty string)\n -e, --exclude-empty-array\n Exclude keys that contain an empty array value\n\nAdding a new lines to each top-level object in our ``test.json`` with\n\n``\"null\": null, \"empty_object\": {}, \"empty_array\": [], \"empty_string\": \"\", \"empty_int\": 0, \"empty_float\": 0.0,``\n\nWe can make some sample calls such as\n\n``bash $ cat test.json | json-inspect keys facebook.null facebook.empty_object facebook.user.demographic.regions.name facebook.empty_float facebook.empty_array # ...``\n\n``bash # filter all keys with empty values $ cat test.json | json-inspect keys -nope facebook.user.demographic.regions.name google.user.demographic.regions.name twitter.user.demographic.regions.name``\n\nPlanned Improvements\n--------------------\n\n[ ] Refactor code to be testable (maybe write some test) [ ] Add support\nfor ``**``\n\n.. |PyPI version| image:: https://badge.fury.io/py/json-inspect.svg\n :target: https://badge.fury.io/py/json-inspect\n.. |PyPI license| image:: https://img.shields.io/pypi/l/json-inspect.svg?maxAge=2592000\n :target: https://github.com/JohnMurray/json-inspect/blob/master/LICENSE", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/JohnMurray/json-inspect", "keywords": null, "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "json-inspect", "package_url": "https://pypi.org/project/json-inspect/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/json-inspect/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/JohnMurray/json-inspect" }, "release_url": "https://pypi.org/project/json-inspect/0.1.6/", "requires_dist": null, "requires_python": null, "summary": "JSON inspection command line client", "version": "0.1.6" }, "last_serial": 2287168, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "d7c276d98a4dffbe29268c870edcb42f", "sha256": "48e3eb52a0f9a86464d73fae414be79584cec2cf817b4920ebc0c56a01b0f4bf" }, "downloads": -1, "filename": "json-inspect-0.0.0.tar.gz", "has_sig": false, "md5_digest": "d7c276d98a4dffbe29268c870edcb42f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2633, "upload_time": "2016-08-05T22:14:02", "url": "https://files.pythonhosted.org/packages/0a/1b/92002b722b155d6fd8fda3e36d58222639ec67eab4a86844defb04900e32/json-inspect-0.0.0.tar.gz" } ], "0.1.0": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "eda50f224b2594fe77ea9a641dfea2c5", "sha256": "aab2373bac77e3da6c4bde632191c92beeae001c61a9a67ba56a1d5d5cf478b3" }, "downloads": -1, "filename": "json-inspect-0.1.1.tar.gz", "has_sig": false, "md5_digest": "eda50f224b2594fe77ea9a641dfea2c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4708, "upload_time": "2016-08-06T15:43:19", "url": "https://files.pythonhosted.org/packages/52/33/a39c6199bcec1e7ebad5285c0cebc525469d16078d00a1d10162851a28d7/json-inspect-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "42d538ad29cc40c7ac42061832c39b99", "sha256": "e5c6a6666db4d63f60c1b5455d352a2b4aefad95b3fa62789460ef18d568913b" }, "downloads": -1, "filename": "json-inspect-0.1.2.tar.gz", "has_sig": false, "md5_digest": "42d538ad29cc40c7ac42061832c39b99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5218, "upload_time": "2016-08-09T21:08:26", "url": "https://files.pythonhosted.org/packages/53/d0/1be1f484380be49fc2e1766fdf969bde3fe6a625070b6a949180db993b1b/json-inspect-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "b123b0eb2d74a854f2e6925572181174", "sha256": "d2c94a0495994c5bbf110d461f7cdafeab52589de72a80c186c8b316c8dd6082" }, "downloads": -1, "filename": "json-inspect-0.1.3.tar.gz", "has_sig": false, "md5_digest": "b123b0eb2d74a854f2e6925572181174", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5212, "upload_time": "2016-08-09T21:31:18", "url": "https://files.pythonhosted.org/packages/88/f4/b2bf12344face50c7d011ea7b8a94c08645b38692bb0fe2f8e832c51e311/json-inspect-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "09a8c7a396c923d9983cc7722564f23c", "sha256": "6ce7a14556a250a49f1e93c4add2a4b5f7e804cf957b14a0d8b6f90b91a2815e" }, "downloads": -1, "filename": "json-inspect-0.1.4.tar.gz", "has_sig": false, "md5_digest": "09a8c7a396c923d9983cc7722564f23c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5580, "upload_time": "2016-08-17T02:11:32", "url": "https://files.pythonhosted.org/packages/b5/c8/c84b55a76346c0cddcc69e59b17c56ae2c0bfbfbea95be723354dea8f445/json-inspect-0.1.4.tar.gz" } ], "0.1.5": [], "0.1.5a": [ { "comment_text": "", "digests": { "md5": "9fa6d1f430ae14a4e727feb91e50977a", "sha256": "07cd824205e532817b634e5eb4ac08a75c26420aa20fa7a782604436ff92edb6" }, "downloads": -1, "filename": "json-inspect-0.1.5a.tar.gz", "has_sig": false, "md5_digest": "9fa6d1f430ae14a4e727feb91e50977a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6373, "upload_time": "2016-08-17T21:06:39", "url": "https://files.pythonhosted.org/packages/d4/41/0315c46242bebb1da546214822a70c2338be9f0275ac93212b2b18077eea/json-inspect-0.1.5a.tar.gz" } ], "0.1.5b": [ { "comment_text": "", "digests": { "md5": "6cae23e5d252ae2d6e16e8d98024f7b8", "sha256": "1722cfc7bf8af1188c8847ab32b64d3f471678e8e8bbb5e2c3ceefa084921847" }, "downloads": -1, "filename": "json-inspect-0.1.5b.tar.gz", "has_sig": false, "md5_digest": "6cae23e5d252ae2d6e16e8d98024f7b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6292, "upload_time": "2016-08-17T21:34:23", "url": "https://files.pythonhosted.org/packages/04/2e/12ee748ce9f88db4ff1b8e38057893b0b30e6fbd7c6cb387a359bd3eec42/json-inspect-0.1.5b.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "9bce73f6fcfd021d0668d11e996e859e", "sha256": "d45368bf7635693cc11ae045c64e5061c999fe1f05566af5b16bd1166d7f10cb" }, "downloads": -1, "filename": "json-inspect-0.1.6.tar.gz", "has_sig": false, "md5_digest": "9bce73f6fcfd021d0668d11e996e859e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6290, "upload_time": "2016-08-17T21:34:55", "url": "https://files.pythonhosted.org/packages/4d/03/1812e4a6222ec259d2622f5b0f87351ef9a53469937f4373db8b99c21c0c/json-inspect-0.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9bce73f6fcfd021d0668d11e996e859e", "sha256": "d45368bf7635693cc11ae045c64e5061c999fe1f05566af5b16bd1166d7f10cb" }, "downloads": -1, "filename": "json-inspect-0.1.6.tar.gz", "has_sig": false, "md5_digest": "9bce73f6fcfd021d0668d11e996e859e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6290, "upload_time": "2016-08-17T21:34:55", "url": "https://files.pythonhosted.org/packages/4d/03/1812e4a6222ec259d2622f5b0f87351ef9a53469937f4373db8b99c21c0c/json-inspect-0.1.6.tar.gz" } ] }