Convert json to python object and vice versa
Project description
Jangli
Scope
- Data Definition
- Data mapping
[1] Convert json to python object.
from json_utils.json_to_object import json_to_obj
data = '{"password": "123456", "id": 1, "name": "abhimanyu"}'
class Student:
def __init__(self):
self.id = None
self.name = None
self.password = None
s = json_to_obj(data, Student)
print(s.name)
[2] Convert json to python object.
from json_utils.json_to_object import json_to_obj
data_2 = '{"password": "123456", "id": 1, "name": "abhimanyu", "school" : "SOHS"}'
class Student:
school = None
def __init__(self):
self.id = None
self.name = None
self.password = None
s2 = json_to_obj(data_2, Student)
print(s2.school)
[3] Custom object list
class A:
def __init__(self, b):
self.b = b
lt = ListObject(A)
lt.append(A(7))
lt.insert(1, A(8))
print(lt)
Output : [<__main__.A object at 0x00CA3730>, <__main__.A object at 0x00CC6E10>]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jangli-1.1.0.tar.gz
(1.8 kB
view details)
Built Distribution
File details
Details for the file jangli-1.1.0.tar.gz
.
File metadata
- Download URL: jangli-1.1.0.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.7.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
02e5d27203718d2ebea4bae6d99da45e892d34baeb44a9c852e9799d69bf3983
|
|
MD5 |
647415942e20e086687ae7ad2e73d668
|
|
BLAKE2b-256 |
9b997c8aaae9cde6890c2dd81fcda14feb5bce01091aaa1719693045fc694681
|
File details
Details for the file jangli-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: jangli-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.7.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
acec364612eede36ebd72ba156c91a265f1daaa400c4f753447d811170d5db1d
|
|
MD5 |
8c1c6f3e0a451fc93398126f19fb0b45
|
|
BLAKE2b-256 |
5e27b0e68137a28f01e6fc8ae74e32b5c9cb8b257ded5c57a5506c7b117f324f
|