Description
This package accepts a nested json as input parameter and provides a flat structured json as output. The output data has additional attributes that help maintaining the relational integrity of the data with parent and child.
Installation
pip install nested-json2rel-data
Usage example
{
"name": "Peter Parker",
"job" : "developer",
"organization": "Daily Bugle",
"address":{"country":"Scotland",
"state":"Wishaw",
"city":"Glasgow",
"pin":"BA1 2FJ"
},
"email":["peter.parker@gmail.com"
,"peter_parker@yahoo.com",
{"primary":"peter.parker@microsoft.com"
,"secondary":"peter.parker@ibm.com"}],
"education":[
{"degree": "Bachelor in Media",
"university":"MIT",
"school name":"MIT",
"contact no":[1,2]
},
{"degree":"Media and Journalism",
"university":"oxford",
"school":"Oxford",
"contact no":[3,4]
},
{"degree":"Social Science",
"university":"Cambridge",
"school":"Cambridge",
"contact no":[5,6]
}
],
"other":{"dob":"10-08-2001",
"parent":{"mother":"Mary Parker",
"father":"Richard Parker",
"brother":"Harry Osborn",
"gardian":{"primary":"self",
"secondary":"mother"},
"grandie":{"Uncle":"Ben Parker",
"auntie" : "Mary Parker"}
},
"birth place": "20 Ingram",
"interest":["football","painting","photography","DIY"]
},
"social":{"facebook":"yes",
"instagram":"yes",
"twitter":"no"
}
}
import json
from nested_json2rel_data import nested_json_parser as njp
with open('json_data.json') as json_file:
data = json.load(json_file)
p = njp.nested_json_parser(data)
d=p.bucket()
print("*************dict :")
print(d)
*************dict :
[{'root_id': 4, 'root_name': 'address', 'child_of': 'root', 'child_of_id': 0, 'country': 'Scotland', 'state': 'Wishaw', 'city': 'Glasgow', 'pin': 'BA1 2FJ'}, {'root_id': 2, 'root_name': 'email', 'child_of': 'root', 'child_of_id': 0, 'email': 'peter.parker@gmail.com'}, {'root_id': 3, 'root_name': 'email', 'child_of': 'root', 'child_of_id': 0, 'email': 'peter_parker@yahoo.com'}, {'root_id': 12, 'root_name': 'email', 'child_of': 'root', 'child_of_id': 0, 'primary': 'peter.parker@microsoft.com', 'secondary': 'peter.parker@ibm.com'}, {'root_id': 5, 'root_name': 'contact no', 'child_of': 'education', 'child_of_id': 12, 'contact no': 1}, {'root_id': 6, 'root_name': 'contact no', 'child_of': 'education', 'child_of_id': 12, 'contact no': 2}, {'root_id': 12, 'root_name': 'education', 'child_of': 'root', 'child_of_id': 0, 'degree': 'Bachelor in Media', 'university': 'MIT', 'school name': 'MIT'}, {'root_id': 6, 'root_name': 'contact no', 'child_of': 'education', 'child_of_id': 13, 'contact no': 3}, {'root_id': 7, 'root_name': 'contact no', 'child_of': 'education', 'child_of_id': 13, 'contact no': 4}, {'root_id': 13, 'root_name': 'education', 'child_of': 'root', 'child_of_id': 0, 'degree': 'Media and Journalism', 'university': 'oxford', 'school': 'Oxford'}, {'root_id': 7, 'root_name': 'contact no', 'child_of': 'education', 'child_of_id': 15, 'contact no': 5}, {'root_id': 8, 'root_name': 'contact no', 'child_of': 'education', 'child_of_id': 15, 'contact no': 6}, {'root_id': 15, 'root_name': 'education', 'child_of': 'root', 'child_of_id': 0, 'degree': 'Social Science', 'university': 'Cambridge', 'school': 'Cambridge'}, {'root_id': 31, 'root_name': 'gardian', 'child_of': 'parent', 'child_of_id': 27, 'primary': 'self', 'secondary': 'mother'}, {'root_id': 34, 'root_name': 'grandie', 'child_of': 'parent', 'child_of_id': 27, 'Uncle': 'Ben Parker', 'auntie': 'Mary Parker'}, {'root_id': 27, 'root_name': 'parent', 'child_of': 'other', 'child_of_id': 25, 'mother': 'Mary Parker', 'father': 'Richard Parker', 'brother': 'Harry Osborn'}, {'root_id': 5, 'root_name': 'interest', 'child_of': 'other', 'child_of_id': 25, 'interest': 'football'}, {'root_id': 6, 'root_name': 'interest', 'child_of': 'other', 'child_of_id': 25, 'interest': 'painting'}, {'root_id': 7, 'root_name': 'interest', 'child_of': 'other', 'child_of_id': 25, 'interest': 'photography'}, {'root_id': 8, 'root_name': 'interest', 'child_of': 'other', 'child_of_id': 25, 'interest': 'DIY'}, {'root_id': 25, 'root_name': 'other', 'child_of': 'root', 'child_of_id': 0, 'dob': '10-08-2001', 'birth place': '20 Ingram'}, {'root_id': 39, 'root_name': 'social', 'child_of': 'root', 'child_of_id': 0, 'facebook': 'yes', 'instagram': 'yes', 'twitter': 'no'}, {'root_id': 0, 'root_name': 'root', 'child_of': 'root', 'child_of_id': 0, 'name': 'Peter Parker', 'job': 'developer', 'organization': 'Daily Bugle'}]
Definitions
| Attribute | Parameter | Description |
|---|---|---|
| nested_json_parser.nested_json_parser(data) | data | Json data |
| p.bucket() | None | not required |
Source code
Metadata
Release files for nested-json2rel-data 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nested_json2rel_data-0.0.2.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nested_json2rel_data-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.9 kB
Release files / nested_json2rel_data-0.0.2.tar.gz
| Download URL | nested_json2rel_data-0.0.2.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e741fadf08ed56d3f22bd24ec84b9cd1cb9ff00a619ebe74aa8d4a1266f575ef
|
|
BLAKE2b-256 checksum How to use checksums |
30aa6e64c556d983168b5e4deb225e15627d01c1fbd97467b2381228f67ebdce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3
|
Release files / nested_json2rel_data-0.0.2-py3-none-any.whl
| Download URL | nested_json2rel_data-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71b4e539c16d931d4f6a641cdc1f546c916ea639a3d1a9970ec1ceed625670d5
|
|
BLAKE2b-256 checksum How to use checksums |
37e58d1f578ddf1c73ca1686ca813c25ed7fb68e704eb589eb065ddbcade28c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3
|