Skip to main content

A project for reading JSON data and parse it for DF, with ability to make you edits to Json, insert values, delete values, update values and search for any values.

Reason this release was yanked:

Deprecated & moved to FiJson

Project description

JsonDF [Json parser for DataFrane usage]

This package is a package for converting nested Json/Dictionaries/Lists for DataFrame usage

Download

for latest release

pip install JsonDF==1.0.3

Normal Usage

and to use it :

from JsonDf.Data import Data

data = Data(prefix="your_prefered_prefix_default_is_root", data=YourJson)

data.childs() #for processing the childs of the Json/Dict/List
print(data.rows) #organized dictionary with the data !! Not for DataFrame usage
data.flatten() #for flattening the result for DataFram usage
print(data.rows_flatten) #flatten the data for DataFrame usage

Json type usage

In Json type you have the ability to parse Json/Dict in the sameway it parsed in JQuery, in addition to the ability to make objects automatically from json/dict

create Json

to use it :

from Json.utils.Json import Json

some_json = {
  'keys' : {
    "another_key": "some_value",  
    },
}

json = Json(json=some_json, name=any_name)
json.objectify()
print(json)
print(json.keys)
print(json.keys.another_key)

insert and update values in Json

you can add values inside the Json as you want, use the insert method

json.insert(name='name', value='value')

keep in mind that you add in the base level, which mean that if you have two Jsons inside each other, and you want to add in the secod Json, you need to access it first to add in it. I'll try to fix this problem later.

NOTE : you can update values in Json by using the same insert method if the name is already exist.

delete values totally

you can totally delete keys and its values from the Json using the delete method, in this case the name and its value will be deleted

json = Json(name='json_name', json={'key': 'value'})
json.delete('key')
print(json')

#  output :
#  {}
#  empty because the 'key' key and it's values is deleted

you've to know that when you delete a key, it's deleted the Json object it self not from the original template it has started with, so if the edits was made in the json was new and was made by JsonDf, deleting it will delete it with no coming back.

dumping values from keys

you can dump values from keys and make the key equals to empty value depends on its type, by using the dump() method

json = Json(name='json_name', json={'key': 'value'})
json.dump('key')
print(json')

#  output :
#  {'key': ''}
#  empty because the 'key' key and it's values is deleted

the type of the value is determined with the same type that it was with in the Json Object, to change it you've to update it with the insert() method after the objectify() other wise it will still with the same type.

feel free to contribute in this project.

cheers.

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

jsondf-1.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

jsondf-1.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file jsondf-1.1.1.tar.gz.

File metadata

  • Download URL: jsondf-1.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for jsondf-1.1.1.tar.gz
Algorithm Hash digest
SHA256 3f406ea7f94688107bbdb36e107d4994a34ecdec658e9dbc1af788882db3b0b3
MD5 30a3071ab92c2e30b7f6a0e8959d4956
BLAKE2b-256 52f3922d06a5553f98a212fd0d5b2be1c998b5a52c73880c84bc2cc00c558df1

See more details on using hashes here.

File details

Details for the file jsondf-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsondf-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for jsondf-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c80f39afbfa49d3a7613593ac72aa34b909b7ed7489c7ee58393b8fa8b14a8c5
MD5 a28b47ebefd7f97cb09d71ded54bac38
BLAKE2b-256 60afcc8dfe671b1e44514cf77436add86dae4298a03966f874330111f30af3f4

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