GithubHelp home page GithubHelp logo

joish / jsonj Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 37 KB

a library to parse JSON tree data to make life easier when working with JSON data

License: MIT License

Python 100.00%

jsonj's Introduction

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

jsonj's People

Contributors

joish avatar

Stargazers

TALAT avatar Arthur Endlein avatar

Watchers

James Cloos avatar  avatar

Forkers

sugumar-dckap

jsonj's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.