Skip to main content

A library to prase Json Tree data in-order to make things simpler

Project description

JSONJ

JsonJ is a simple Python Library that allows parsing Complicated Nested Json tree to a Simple Json data. This Library allows converting Complicated Nested Json Data to an Intermediate Simple Json Data, which make it easier to process the original data.

Example Data Conversion

########################## FROM #########################################
{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}

###########################  TO #########################################
{
  'menu': {
   'path': 'menu',
   'isRoot': True,
   'children': ['menu/id', 'menu/value', 'menu/popup']
  },
  'menu/id': {
   'path': 'menu/id',
   'isRoot': False,
   'children': []
  },
            .
            .
            .
  'menu/popup/menuitem/2/value': {
   'path': 'menu/popup/menuitem/2/value',
   'isRoot': False,
   'children': []
  },
  'menu/popup/menuitem/2/onclick': {
   'path': 'menu/popup/menuitem/2/onclick',
   'isRoot': False,
   'children': []
  }
}

As you can see, this converted format is Elegant and can be Applied to a Various Task.

Converted Data Format Description

            .
            .
            .
'menu/popup/menuitem/2/value': {
   'path': 'menu/popup/menuitem/2/value',
   'isRoot': False,
   'children': []
  },
            .
            .
            .
  • The key of the data is set to be the path of that particular node from the root Node
  • Each Key has a value which in turn is a simple Json with 3 parameters.
    • path: The path of the particular node from the root node (same as that of the key)
    • isRoot: Either it's a Root node or not
    • children: Wheather the particular node has any children or not

Installation

$ pip3 install JsonJ

Usage

from JsonJ import JsonJ
json = JsonJ(<sample_json_data>)

NOTE: PLEASE MAKE SURE THE JSON DATA IS VALID, AS OF NOW THE LIBRARY DOES NOT CHECK WHETHER THE DATA IS VALID OR NOT, BUT THIS VALIDATION WILL BE DONE SOON

Detailed Usage

- get_parsed_data() - This function call returns the Intermediate Parsed data
- clean() - This function call clears all the data saved in local variables

Development

Want to contribute? Great! All you have to do is a Pull Request and start Working

Todo's

  • Search by node
  • Search by value
  • Json data validator
  • And a lot has to be done

License

MIT

PEACE

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for JsonJ, version 0.1.6
Filename, size File type Python version Upload date Hashes
Filename, size JsonJ-0.1.6-py3-none-any.whl (4.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size JsonJ-0.1.6.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page