Skip to main content

measyjson

A small Python library to make storing and manipulating JSON data easier.

Python 3.9 et superieur. Aucune dependance a l'installation.

Installation

python -m pip install measyjson

Le paquet s'installe sous le nom measyjson, mais le module s'importe toujours sous le nom easyjson.

Installation depuis les sources

python -m pip install -e .

Usage

import easyjson
from easyjson import core

chemin = "comptes.json"

write, append, write_add et base_json sont exportes par easyjson. read_chaine et delete ne le sont pas, ils s'importent via easyjson.core.

write

Ecrit du contenu brut dans un fichier, en ecrasant l'existant. Aucune validation JSON, le contenu est ecrit tel quel.

easyjson.write(chemin, '{"Account": {"user": "sionukk", "password": "secret"}}')

Retourne (chemin, contenu).

write_add

Ajoute une cle a un objet JSON existant. La valeur passe par une f-string, elle est donc toujours stockee comme du texte.

core.write_add(chemin, "ville", "Nimes")

Une cle deja presente n'est pas remplacee. Le deuxieme element du retour indique si l'ecriture a eu lieu.

easyjson.write(chemin, "{}")

core.write_add(chemin, "ville", "Nimes")   # (chemin, True,  "Nimes")
core.write_add(chemin, "ville", "Lyon")    # (chemin, False, "Lyon"), le fichier garde "Nimes"

Avec une cle vide, la fonction ne fait rien et renvoie (chemin, "", contenu), un tuple de forme differente des deux chemins ci-dessus.

append

Pousse un element a la fin d'une liste JSON, puis reecrit le fichier avec une indentation de 4 espaces.

easyjson.write(chemin, '["Nimes", "Lyon"]')
core.append(chemin, "Marseille")          # ["Nimes", "Lyon", "Marseille"]

Le type de la valeur ajoutee est conserve tel quel.

read_chaine

Retourne la valeur stockee sous une cle, sans modifier le fichier. La fonction imprime aussi la valeur sur la sortie standard.

core.read_chaine(chemin, "ville")          # "Nimes"

Le type stocke est conserve : un nombre reste un nombre, une liste reste une liste.

delete

Supprime une cle d'un objet JSON. Si la cle etait la derniere, le fichier reste present avec un objet vide {}.

core.delete(chemin, "ville")               # (chemin, "ville")

Une cle absente leve KeyError avant l'ouverture du fichier en ecriture, le fichier n'est donc pas touche.

base_json

Cree un squelette de compte et vise data.json dans le repertoire courant.

data = easyjson.base_json()
# {"Account": {"user": "username", "password": "password"}}

Le dict est serialise avec json.dump(data, f, indent=4), donc data.json recoit du JSON valide. La fonction retourne le dict ecrit. Elle leve OSError si le repertoire courant n'est pas inscriptible.

Exceptions

Fonction Condition Exception
write dossier inexistant OSError
append fichier inexistant OSError
append JSON invalide json.JSONDecodeError
append JSON pas une liste AttributeError
write_add dossier inexistant OSError
write_add JSON invalide json.JSONDecodeError
write_add JSON pas un objet TypeError
write_add cle vide aucune, no-op
read_chaine dossier inexistant OSError
read_chaine JSON invalide json.JSONDecodeError
read_chaine cle absente KeyError
read_chaine JSON pas un objet TypeError
delete dossier inexistant OSError
delete JSON invalide json.JSONDecodeError
delete cle absente KeyError
delete JSON pas un objet TypeError
base_json repertoire non inscriptible OSError

json.JSONDecodeError herite de ValueError. Les blocs except de write, append, read_chaine et delete attrapent ValueError, donc aussi une erreur de decodage.

Tests

python -m unittest discover -s tests -v

or, with uv:

uv run pytest

Lint et annotations:

uv run ruff check .
uv run mypy

Le CI lance les tests de Python 3.9 a 3.13, et ruff et mypy sur 3.13 uniquement, mypy exigeant 3.10 minimum.

Voir docs/index.html pour le guide d'ecriture des tests.

License

MIT

Metadata

Release files for measyjson 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for measyjson 0.1.3
File Size Uploaded Provenance Actions
measyjson-0.1.3.tar.gz 8.5 kB With provenance Details for measyjson-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for measyjson 0.1.3
File Interpreter ABI Platform Actions
measyjson-0.1.3-py3-none-any.whl Python 3 none any Details for measyjson-0.1.3-py3-none-any.whl

Total release size: 14.0 kB

Release files / measyjson-0.1.3.tar.gz

Download URL measyjson-0.1.3.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e63dea8ed8c3a2857e0e768619ef9e05fdc9bf19b0db5dba0945752edb8c5b94
BLAKE2b-256 checksum
How to use checksums
5f5451d9a822b6ec92a76fd6a2b1955ef0d230b6c5463aed45b1551dce16a87f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / measyjson-0.1.3-py3-none-any.whl

Download URL measyjson-0.1.3-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85d5375ea66b9a8711e1a23840a9abd4524eb5d54f66e5fcdc7717b4ab537833
BLAKE2b-256 checksum
How to use checksums
d560ec518a05cf4a86758c2a9c19685a3d1413fbf94e8635c4cb66f4e3bfb792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Security for measyjson 0.1.3

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for measyjson-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page