Skip to main content

Inspect and extract JSON structure safely with optional fields and type merging

Project description

🔍 jsonlens

See the structure of any JSON instantly — without exposing sensitive data.


🚀 Why jsonlens?

Working with APIs is painful:

  • ❌ Huge JSON responses (1000+ lines)
  • ❌ Deeply nested structures
  • ❌ Sensitive data you cannot share

👉 jsonlens converts JSON into a clean, safe structure.


✨ Features

  • 🔐 Safe — no real values, only structure
  • ❓ Optional fields detection (email?)
  • 🔄 Type merging (int | str)
  • 📦 List compression (... N more items)
  • ⚡ Fast / Sample / Full modes

📦 Installation

pip install jsonlens

⚡ Basic Usage

from jsonlens import build_structure
import json

data = {
    "users": [
        {"id": 1, "name": "Alice"},
        {"id": 2, "name": "Bob", "email": "bob@mail.com"}
    ]
}

result = build_structure(data, mode="full")

print(json.dumps(result, indent=2))

🧾 Output

{
  "users": [
    {
      "id": "int",
      "name": "str",
      "email?": "str"
    }
  ]
}

🧠 Explanation

  • email? → optional field (not present in all items)
  • int | str → multiple possible types
  • ... N more items → repeated structure compressed

⚙️ Modes

build_structure(data, mode="fast")    # first item only
build_structure(data, mode="sample")  # few items
build_structure(data, mode="full")    # full scan
Mode Description
fast fastest, less accurate
sample balanced
full most accurate

🔥 Example: Nested JSON

data = {
    "orders": [
        {
            "id": 1,
            "items": [{"name": "Laptop"}, {"name": "Mouse"}]
        },
        {
            "id": 2,
            "items": [{"name": "Keyboard"}]
        }
    ]
}

print(json.dumps(build_structure(data, mode="full"), indent=2))

🧾 Output

{
  "orders": [
    {
      "id": "int",
      "items": [
        {
          "name": "str"
        },
        "... 1 more items (same structure)"
      ]
    },
    "... 1 more items (same structure)"
  ]
}

🔐 Safe for AI Usage

Instead of sharing real API data:

❌ Original:

{
  "email": "user@gmail.com"
}

✅ With jsonlens:

{
  "email": "str"
}

🤝 Contributing

  1. Fork the repo
  2. Create a branch
  3. Make changes
  4. Open a Pull Request

⭐ Support

If you find this useful:

  • ⭐ Star the repository
  • Share with other developers

🪪 License

MIT License

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

jsonlens-0.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.

jsonlens-0.1.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file jsonlens-0.1.1.tar.gz.

File metadata

  • Download URL: jsonlens-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for jsonlens-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4a2daed0f68d85f996d25f4bf7662bd058711b8a3e7a5cb5fa3f31994abd0426
MD5 b78efc1c83a33c18efe031b857ebbfb4
BLAKE2b-256 7c124402802479ee87c600fc22b90a47d036ffed886c48b93a480c456fe2a230

See more details on using hashes here.

File details

Details for the file jsonlens-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsonlens-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for jsonlens-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4db2e6f72f2095c79a2276b28a0c1041bd6ce6c42311309114f3f5ec210c450b
MD5 a443a6c7ac25598d9679bc82c9a7176a
BLAKE2b-256 43d18b4a2bbcfac20235048bb33b3b108b3a4ffb8f53391d12eec12c5e6ea3f6

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