📦 SmartJsonPy
SmartJsonPy é um pacote Python leve e poderoso para manipulação de JSON. Ele oferece funções para validação, limpeza, extração, deduplicamento e conversão de dados JSON. Ideal para preparação de dados, integrações com APIs e exportação para planilhas.
🧪 Testes
Execute os testes com pytest:
pytest tests/
🚀 Instalação
pip install SmartJsonPy
Requer: Python >= 3.7
✨ Funcionalidades
✅ Validação de JSON
from SmartJsonPy import validator
validator.is_valid_json_string('{"nome": "João"}') # True
validator.is_valid_json_object({"id": 1}) # True
validator.has_required_keys({"id": 1}, ["id"]) # True
validator.is_json_schema_compatible({"id": 1}, {"id": int}) # True
🧹 Limpeza de dados
from SmartJsonPy import cleaner
data = {"a": 1, "b": None, "c": "", "d": []}
cleaner.remove_none_values(data) # {"a": 1, "c": "", "d": []}
cleaner.remove_empty_values(data) # {"a": 1}
cleaner.strip_whitespace_keys({" nome ": "Ana"}) # {"nome": "Ana"}
nested = {"x": {"y": {"z": None}}, "a": ["ok", {}]}
cleaner.clean_nested_dict(nested) # {"a": ["ok"]}
🔍 Extração de dados
from SmartJsonPy import extractor
data = {"a": 1, "b": {"a": 2}, "c": [{"a": 3}, {"x": 9}]}
extractor.extract_keys(data) # ['a', 'b', 'c', 'x']
extractor.extract_values_by_key(data, "a") # [1, 2, 3]
🔁 Deduplicar dados
from SmartJsonPy import utils
# Dicionários duplicados
lst = [{"a": 1}, {"a": 1}, {"b": 2}]
utils.remove_duplicate_dicts(lst) # [{"a": 1}, {"b": 2}]
# Itens duplicados
nums = [1, 2, 2, 3, 1]
utils.remove_duplicate_items(nums) # [1, 2, 3]
🔄 Conversões entre string e JSON
from SmartJsonPy import utils
# JSON para string
d = {"nome": "João"}
utils.json_to_string(d) # '{"nome": "João"}'
# String para JSON
s = '{"nome": "Maria"}'
utils.string_to_json(s) # {'nome': 'Maria'}
🔄 Transformação de Dados
from SmartJsonPy import transformer
# JSON para YAML
data = {"nome": "João", "idade": 30}
yaml_str = transformer.json_to_yaml(data)
# name: João
# age: 30
# JSON para XML
xml_str = transformer.json_to_xml(data, root_name="pessoa")
# <?xml version="1.0" encoding="utf-8"?>
# <pessoa>
# <nome>João</nome>
# <idade>30</idade>
# </pessoa>
# JSON para CSV
lista = [
{"nome": "João", "idade": 30},
{"nome": "Maria", "idade": 25}
]
csv_str = transformer.json_to_csv(lista)
# nome,idade
# João,30
# Maria,25
# Achatamento de JSON
nested = {"a": {"b": {"c": 1}}}
flat = transformer.flatten_json(nested)
# {"a.b.c": 1}
# Desachatamento de JSON
nested = transformer.unflatten_json({"a.b.c": 1})
# {"a": {"b": {"c": 1}}}
📊 Conversão para formato de colunas (planilhas)
from SmartJsonPy import utils
lista = [
{"name": "Roberto", "age": 45, "gender": "m"},
{"name": "Joao", "age": 32, "gender": "m"},
{"name": "Renata", "age": 39, "gender": "f"}
]
utils.convert_list_of_dicts_to_columns(lista)
# (
# ('name', 'age', 'gender'),
# ('Roberto', 'Joao', 'Renata'),
# (45, 32, 39),
# ('m', 'm', 'f')
# )
👨💻 Autor
Desenvolvido por Roberto Lima 🚀✨
💬 Contato
- 📧 Email: robertolima.izphera@gmail.com
- 💼 LinkedIn: Roberto Lima
- 💼 Website: Roberto Lima
- 💼 Gravatar: Roberto Lima
📄 Licença
MIT License
Metadata
Release files for SmartJsonPy 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| smartjsonpy-1.1.1.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smartjsonpy-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / smartjsonpy-1.1.1.tar.gz
| Download URL | smartjsonpy-1.1.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60322b82ab97cf726484878e1f18a87a16c65524163e0a8263ba0c0ce2247df0
|
|
BLAKE2b-256 checksum How to use checksums |
1e0023e4f22761f0c99e0988f94f4ade36dc2e5bb2d6bdabd3b235241b2ef7ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / smartjsonpy-1.1.1-py3-none-any.whl
| Download URL | smartjsonpy-1.1.1-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ae2624bcbbf60fb686f216cce55c39f71693aef2cfbce6a72b6ee9d27c4299e
|
|
BLAKE2b-256 checksum How to use checksums |
fa003b67111e4bbc3fec5366923cd759b55f61d3177ff3d8e0b327f4e5df33b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for SmartJsonPy 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.