Skip to main content

Easy JSON2JSON

Description

A python package for deep JSON translation.

You just need to specify you template to get all data from another JSON to avoid doing that manually in your code.

Install

pip install easy-json2json

Usage example

Case #1 Simple JSON

from easyjson2json import Json2Json

source = {"name": "Test Name"} # source JSON

template = {"first_name": "name"} # this is the structure you want your new JSON be 

translator = Json2Json(template=template, source=source)

result = translator.get_result()       

print(result)

# {'first_name': 'Test Name'}

Case #2 Different structure

from easyjson2json import Json2Json

source = {"name": "Test Name", "address": {"name": "My Street", "number": 23}} # when is not a plain JSON

template = {"first_name": "name", "address_name": ["address", "name"]} # you don't want all that structure 

translator = Json2Json(template=template, source=source)

result = translator.get_result()       

print(result)

# {'first_name': 'Test Name', 'address_name': 'My Street'}

Case #3 From ugly JSON

from easyjson2json import Json2Json

source = {"name": "My Name", "ADDRESS": {"name": "My Street", "number": 23}} # ugly JSON happens 

template = {"name": "name", "address": {"_source": "ADDRESS", "name": "name", "number": "number"}} # you want beautiful JSON

translator = Json2Json(template=template, source=source)

result = translator.get_result()       

print(result)

# {'name': 'My Name', 'address': {'name': 'My Street', 'number': 23}}

Case #4 From List in JSON

from easyjson2json import Json2Json

source = {"name": "My Name", "ADDRESSES": [{"name": "My Street", "number": 23}]} # when you have a list

template = {"name": "name", "addresses": {"_source_": "ADDRESSES", "name": "name", "number": "number"}} # then you get that list beautifuly

translator = Json2Json(template=template, source=source)

result = translator.get_result()       

print(result)

# {'name': 'My Name', 'addresses': [{'name': 'My Street', 'number': 23}]}

Source Code

easyjson2json

Author

2020 brworkit.

License

MIT License.

Metadata

Release files for easy-json2json 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-json2json 0.0.2
File Size Uploaded
easy-json2json-0.0.2.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-json2json 0.0.2
File Interpreter ABI Platform
easy_json2json-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / easy-json2json-0.0.2.tar.gz

Download URL easy-json2json-0.0.2.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1a48def911fe32b4f7be497fbaafde643b77bc01c3588503ac2f3b30b3ba23dd
BLAKE2b-256 checksum
How to use checksums
db8ec8485217ad7087635173d1b240bc73e6ee3f0c6f96d067acae53d8db1e5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3

Release files / easy_json2json-0.0.2-py3-none-any.whl

Download URL easy_json2json-0.0.2-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c92202d881f773d5b404a49f86430531a8ef192242d622477631b7350145cbf
BLAKE2b-256 checksum
How to use checksums
54f9082c4a2f4b0f2ceac7539bf6874bd35ef0221c14a8e5b27a6126818463aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page