Skip to main content

Json shorthand for python

Project description

# J

Python shorthand for json. inspired by [q](https://pypi.org/project/q/)

This package allows json load, dump from and to file with few code.

## Installation

```bash
pip install jshort
```

## Usage

```python
import j #This is an instance

# loads json from file, stores it in data property
h = j(input_path='/tmp/data.json')

# get data
h.data
#{"foo": "bar"}

# Display colored content
print(h)
# or
h.prt()

{
"foo": "bar"
}

# The same, in short
j(i='/tmp/data.json').d
j(i='/tmp/data.json').prt()

# Write json
j(output_path='/tmp/data.json', data={"foo": "bar"})
# Also change print indnentation
h = j(o='/tmp/data.json', data={"hey": "jude"}, indent=2)
h.prt()

{
"hey": "jude"
}

# Traversing json documents using https://pypi.org/project/jsonpath-ng/
j(d=my_dict).path('key')
# Shorter and with more filtering
j(d=my_dict).p('sub.*')
# Or with an array and from a file
j(i='/tmp/data.json').p('key[1]')

```

Enjoy.

Have a look at https://pypi.org/project/jsonpath-ng/ for more about json traversing


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jshort-1.0.2.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jshort-1.0.2-py2.py3-none-any.whl (3.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file jshort-1.0.2.tar.gz.

File metadata

  • Download URL: jshort-1.0.2.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for jshort-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7a915428c1981bf134c589bedfd29f40c5a1789c097b63c504acc318d3b08484
MD5 70a2f254280efa40dd0caaffc0d34026
BLAKE2b-256 a774c292781503dc7f5de98b37ece2444897649b8d01e18bc8c8a4f3ae58952d

See more details on using hashes here.

File details

Details for the file jshort-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: jshort-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for jshort-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 83de0197e38ac248aae67f6c7bde51859c24af90903cb67ad72baa21def6f0c9
MD5 7565b88ec788d958214a7dc59c8f75ec
BLAKE2b-256 dbe5059c3a69947506f9d535c0897edeb103b4f688ee39d4207908d151f0a179

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page