Skip to main content

Project for dynamically converting json types into dynamic python objects

Project description

JSON Tools

Collection of JSON tools for Python 3 that help developers work with JSON (Javascript Object Notation) easier.

The source for this project is available here.

Overview

FrozenJSON

Allows a JSON to be loaded into a pseudo python object dynamically.

This idea and conception was from the book "Fluent Python: Clear, Concise, and Effective Programming" by Luciano Ramalho.

Basic Usage

For example, say we have a JSON in a file that looks like the following:

  {
    "_id": "5e52d75618947399f093ac7d",
    "isActive": false,
    "picture": "http://placehold.it/32x32",
    "latitude": -49.694182,
    "longitude": 126.901299,
    "tags": [
      "non",
      "est",
      "sint"
    ]
  }

If a developer wanted to treat this JSON as a python object, they could create a FrozenJSON using the following syntax:

import FrozenJSON
x = Frozen.of(<file_path>)

print(x.isActive)
...False
print(x.tags)
...["non","est","sint"]
print(x.tags[0])
..."non"

The of method is a dynamic constructor that is able to discern whether the data passed in a JSON string, the path to a file, a reference to a file itself, or a python dictionary.

So something like below is perfectly legal:

import FrozenJSON
data = {
    "name": "Ryan Long",
    "class": "Geometry"
}
x = FrozenJSON.of(data)
print(x.name)
..."Ryan Long"
print(x.class_)
..."Geometry"

Notice that although class is a keyword, FrozenJSON is still able to assign it to a key by appending "_" to the end. This is true for all python keywords that are also used as keys and happens automatically.

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

rlt-json-tools-0.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

rlt_json_tools-0.0.2-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file rlt-json-tools-0.0.2.tar.gz.

File metadata

  • Download URL: rlt-json-tools-0.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

File hashes

Hashes for rlt-json-tools-0.0.2.tar.gz
Algorithm Hash digest
SHA256 fa5b423cfd5b6c911742bb19a6c9edd5712f8731d50839179f68fdaf2a1a57c4
MD5 8611e4648541ac6e9ae2b2cc56373d5d
BLAKE2b-256 a3c780174a6855c879837c61e75803875bf9c08e34bb656b3ed3ed99d2a60069

See more details on using hashes here.

File details

Details for the file rlt_json_tools-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: rlt_json_tools-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

File hashes

Hashes for rlt_json_tools-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b4d0aace4435bc555e80aa511ac9c9e0d4938ac2a0589c9915a2b1457bd7d85c
MD5 3cb7ebf6220c39f362aa492deead6402
BLAKE2b-256 e256a3a97562e7b2e95b9b05b79718f5453acf5c837a96b94b834ed177a81441

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