Skip to main content

A Python package to visualize JSON as a vertical graph(support drf-spectacular).

Project description

PyPI DownloadsPyPI DownloadsPyPI Downloads

JsonCrack 📊

JsonCrack is a Python package that visualizes JSON as a vertical graph to help developers understand complex JSON structures easily Supporting drf-spectacular Schema.


🚀 Features

💚 Convert JavaScript-style JSON (null, true, false) → Python (None, True, False)
💚 Generate vertical graph visualization of JSON data
💚 Automatically detects OS to display the graph (Windows, Mac, Linux)
💚 No need for a web interface—runs locally
💚 Support drf-spectacular—Visualize Django Rest Framework Documentation Example Responses


📚 Installation

  1. Install Graphviz (required for rendering graphs):

    • Windows: Download and install from Graphviz website
    • Mac:
      brew install graphviz
      
    • Linux (Debian/Ubuntu):
      sudo apt install graphviz
      
  2. Install JsonCrack:

    pip install JsonCrack
    

🔥 Quick Start

data is in java script style

1⃣ Convert JavaScript-style JSON to Python

from JsonCrack.Cracker import JSON

data = '''
{
    "name": "Alice",
    "active": true,
    "address": null
}
'''

# Convert JS JSON to Python format
json_obj = JSON(data)
python_json = json_obj.convert_js_to_python()
print(python_json)

🟢 Output:

{'name': 'Alice', 'active': True, 'address': None}

2⃣ Visualize JSON Data

json_obj.visualize(display=True, output_file="visualize_output",)

📌 This will open a PNG file with name visualize_output displaying the JSON structure as a vertical graph.
🟢 Output: visualize_output

3⃣ Convert & Visualize in One Step with display(default)

from JsonCrack.Cracker import JSON
data =  [{
    "name": "Alice",
    "active": True,
    "address": None
},
    {
        "name": "Salma",
    "active": False,
    "address": "New York"
    }
    ]
json_obj = JSON(data)
json_obj.visualize()

🟢 Output: visualize_output

3⃣ Convert & save Visualize in One Step without display

from JsonCrack.Cracker import JSON
data = {
    "name": "Alice",
    "active": True,
    "address": None
}
json_obj = JSON(data)
json_obj.visualize(display=False)

3⃣ Integration With Django

#add this to Django settings.py
REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'JsonCrack.AutoSchema'}

🟢 Example Results: DRF Docs Exapmle http://localhost:8000/media/xhvo+f6^l-\IIXVAMJC1J.png DRF Docs Exapmle 200 http://localhost:8000/media/xhvo+f6^l-\HM2VFKK0VN.png DRF Docs Exapmle 403 http://localhost:8000/media/xhvo+f6^l-\2WB4HC5DAU.png DRF Docs Exapmle 429

🛠 Development

  1. Clone the repository:
    git clone https://github.com/MahmoudGShake/JsonCrack.git
    cd JsonCrack
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Install package in editable mode:
    pip install -e .
    

👥 Contributing

We welcome contributions! 🎉

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Make your changes
  4. Commit and push (git commit -m "Added new feature" && git push origin feature-branch)
  5. Create a pull request

🐝 License

MIT License - Free to use and modify. See LICENSE for details.


💡 Future Improvements

🚧 Planned features:

  • Interactive web-based visualization
  • More export formats (SVG, PDF, JSON Tree)
  • Better error handling for invalid JSON

🌟 Show Your Support

🌟 Star this repository on GitHub if you find it useful!
💬 Feel free to open issues for bug reports & feature requests.


Happy Coding! 🚀

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

jsoncrack-0.2.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

jsoncrack-0.2.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file jsoncrack-0.2.1.tar.gz.

File metadata

  • Download URL: jsoncrack-0.2.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for jsoncrack-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3b3e015cd80e68a266628fd6939a0e7e1ca1ba63d9d3d0c7d6de71d1498ebcf0
MD5 0d81facd38b7649e53300b6807e7223a
BLAKE2b-256 de6c5bce37ed8157420db58de99ff63cf5f1e53ce399638e5ede26f79f12867b

See more details on using hashes here.

File details

Details for the file jsoncrack-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: jsoncrack-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for jsoncrack-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3120f2eb70f0af3a4c828e0c5d18a642444a09740a957a17a15043a46920c881
MD5 bd64e8677a1b233a432e5eb6b4e65f5b
BLAKE2b-256 dc416de3833afaa51bdb92efe39f8acda194125a7f112beff8d4d183840b7810

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