Convert structured text data into JSON easily
Project description
Text2JSON SDK
A lightweight Python SDK to convert structured text (list-based data) into clean JSON format using predefined keys.
🚀 Installation
Install from PyPI:
pip install text2json-sdk
📌 Quick Start
from text2json_sdk import Text2JSON
keys = ["Name", "Enrollment", "Department", "Location"]
data = [
["Gautam", "001", "Production", "Pune"],
["Dhruv", "002", "Production", "Gujarat"]
]
converter = Text2JSON(keys)
# Get Python object
result = converter.fill(data)
print(result)
# Get JSON string
json_result = converter.fill(data, as_json=True)
print(json_result)
🧠 How It Works
- Define a list of keys (schema)
- Provide structured data as list of rows
- SDK maps each row to keys
- Returns JSON-ready output
📦 Example Output
[
{
"Name": "Gautam",
"Enrollment": "001",
"Department": "Production",
"Location": "Pune"
},
{
"Name": "Dhruv",
"Enrollment": "002",
"Department": "Production",
"Location": "Gujarat"
}
]
✅ Features
- Simple and intuitive API
- Converts list-based data into structured JSON
- Handles missing values automatically
- Input validation with clear errors
- Optional JSON string output
⚠️ Error Handling
The SDK raises StructureError in the following cases:
- Keys are not a list of strings
- Keys list is empty
- Data is not a list of lists
- Row contains too many values
- Row format is invalid
Example:
from text2json_sdk import Text2JSON
from text2json_sdk.exceptions import StructureError
try:
converter = Text2JSON(["Name", "Age"])
converter.fill([["Alice", 25, "Extra"]])
except StructureError as e:
print(e)
🧪 Development Setup
Clone the repository and install locally:
git clone <your-repo-url>
cd text2json_sdk
pip install -e .
Run tests (if added):
pytest
Upload to PyPI:
twine upload dist/*
🛠 Future Improvements
- CSV file support
- CLI tool (
text2json file.csv) - Schema validation
- Async support
- Integration with pandas
💡 Philosophy
This SDK focuses on simplicity and developer experience:
"Make structured data transformation effortless and readable."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file text2json_sdk-0.1.0.tar.gz.
File metadata
- Download URL: text2json_sdk-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdf8c09ff3d2343f14d46047651db13572f180a43f5ae0aba542a66643ddec09
|
|
| MD5 |
e0f61fa2f7c61e4d48a28780b47576b4
|
|
| BLAKE2b-256 |
32223a2cb569d6b4d1e147f6e1038945cd0f0d6dc874d2026908a77dcf21fa91
|
File details
Details for the file text2json_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: text2json_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c6ee97dcdf75ac198cd84a12616b04ce9a878533ae88fda9f68585a8643d959
|
|
| MD5 |
88b5d1c8d94460b1f4e4198c99db5a71
|
|
| BLAKE2b-256 |
611f8715d7086ed1f47ee3f3d92d994a7299f328c27b25422c266d450671f77d
|