Jsoner
Convenient and fast adding objects to json file
Installation
pip install jsoner-lib
A simple example
from pydantic import BaseModel
class Dog(BaseModel):
name: str
angry: bool
class Cat(BaseModel):
name: str
lazy: bool
class Person(BaseModel):
name: str
age: str
animals: list[Cat | Dog] | None
"""
the so-called imaginary data that you get, for example, when parsing a website
"""
persons = [
Person(name="Alex", age=40, animals=[Cat(name="Terminator", lazy=False)]),
Person(name="Victor", age=24, animals=[Dog(name="Barsic", angry=True)]),
Person(name="Michle", age=59, animals=[Cat(name="Barbon", lazy=True)]),
Person(name="Tomas", age=42, animals=[Cat(name="Spider", lazy=False)]),
Person(name="Robert", age=30, animals=[Cat(name="Kraul", lazy=True)]),
Person(name="Antony", age=29, animals=[Cat(name="Green", lazy=False)])
]
jsn = Jsoner(models=[Person], filename="persons.json")
for psn in persons:
jsn.append(psn)
jsn.save(indent=4)
## persons.json
"""
[
{
"name": "Alex",
"age": "40",
"animals": [
{
"name": "Terminator",
"lazy": false
}
]
},
{
"name": "Victor",
"age": "24",
"animals": [
{
"name": "Barsic",
"angry": true
}
]
},
{
"name": "Michle",
"age": "59",
"animals": [
{
"name": "Barbon",
"lazy": true
}
]
},
...
...
"""
You can find examples in file /example/
Release files for jsoner-lib 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsoner-lib-0.5.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsoner_lib-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / jsoner-lib-0.5.tar.gz
| Download URL | jsoner-lib-0.5.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47d590a55cbbf2989ca2a1a5894f350860cd0c02ec9bec40a3dce868a4180322
|
|
BLAKE2b-256 checksum How to use checksums |
192e6d4df56cdeac7180010a2b9fcb74bcd6bff8642e236d5dd1515ca7ce89f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / jsoner_lib-0.5-py3-none-any.whl
| Download URL | jsoner_lib-0.5-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88c8ebf2e65b3c4f611e71a9b00db1e8f980b9e2b5077070865db09cb0381890
|
|
BLAKE2b-256 checksum How to use checksums |
f601f69efd36eeedb5a828925794c9329c2a292126f26773ea43c4fb9930db8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|