🗺️ MapPy — JSON ↔ Object Mapper for Python
MapPy is a lightweight JSON-to-object mapper for Python that helps you transform JSON data into strongly-typed Python objects — automatically or by using a predefined root structure. It’s ideal for cases where you: receive dynamic or nested JSON from APIs, want to map them into known Python classes, and still gracefully handle unknown or optional fields.
🚀 Features
🔍 Automatic class matching — detects which Python class best fits a given JSON structure.
🧩 Root-based mapping — map directly using a predefined root object with nested definitions.
🪶 Lightweight — no third-party dependencies, just the Python standard library.
🧠 Smart fallback — unmapped parts become types.SimpleNamespace objects for flexible access.
💡 Simple type handling — primitives (str, int, float, bool, None) are mapped directly.
📦 Installation
pip install mappy-json-object-mapper
The tool is finding the suitable target for mapping automatically
input: json, Object list to find mapping objects from
The json structure is fully defined by a root Object,
input: json, the root Object
🧭 Usage Examples
https://github.com/PazsitZ/mappy-json-object-mapper/blob/master/test/mappy/main.py
🧩 How It Works
MapPy uses Python introspection (inspect.signature) to analyze your class constructors.
It matches JSON keys to constructor arguments and decides which class best fits the input.
If no perfect match is found, MapPy falls back to SimpleNamespace.