Metadata-Version: 2.0
Name: json-get
Version: 1.0.1
Summary: Get values from JSON objects using a path expression
Home-page: https://github.com/srittau/python-json-get
Author: Sebastian Rittau
Author-email: srittau@rittau.biz
License: MIT
Description-Content-Type: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development
Requires-Python: >=3.5

Python JSON Get
===============

.. image:: https://img.shields.io/github/release/srittau/python-json-get/all.svg
   :target: https://github.com/srittau/python-json-get/releases/
.. image:: https://travis-ci.org/srittau/python-json-get.svg?branch=master
   :target: https://travis-ci.org/srittau/python-json-get

Get values from JSON objects usings a path expression. Optional type
checking is possible.

>>> from jsonget import json_get
>>> j = {
...     "foo": {"num": 3.4, "s": "Text"},
...     "arr": [10, 20, 30],
... }
>>> json_get(j, "/foo/num")
3.4
>>> json_get(j, "/arr[1]")
20
>>> json_get(j, "/foo/unknown")
Traceback (most recent call last):
    ...
ValueError: JSON path '/foo/unknown' not found

Values are optionally checked against one of the following types:
str, int, float, bool, list, and dict. Checking for null values is not
supported.

>>> json_get(j, "/foo/num", str)
Traceback (most recent call last):
    ...
TypeError: wrong JSON type str != float

float will match any number, int will only match numbers without
a fractional part.

>>> json_get(j, "/foo/num", float)
3.4
>>> json_get(j, "/foo/num", int)
Traceback (most recent call last):
    ...
TypeError: wrong JSON type int != float


