Package: jsonargon
JSON Argonhttps://gitlab.com/federico_pugliese/jsonargonSerializationanddeserializationofJSONobjects from/intoPythonobjects (withvalidationandremappingcapabilities).The underlying idea is toannotatea PythonClasswith metadata useful to serialize its objects into JSON strings and viceversa.Main features and goals are:ConcisionJSON ValidationOptional remapping of fields nameFamiliar interfaceInstallationTo get the latest stable version, just runpip install jsonargonorpip install jsonargon==<version>if you require a specific version.UsageBasic UsageThe basic requirement is to write the Python Class remapping your JSON.from jsonargon.decorators import jsonclass
from jsonargon.fields.simple import Required, Nullable

@jsonclass
class Person:
    
    name: Required(str)
    age:  Nullable(int)As simple as that. Thenamefield is a required string, while theageis a non-required integer.TheRequiredtype annotation will make sure thatnameis in your JSON string before deserializing it (aKeyErroris thrown otherwise).If you have your JSON string, you can easily remap it into a Python object of that class, after you get your JSON string somehow (probably something like{"name": "Jason Argonaut"}):person = Person.from_json(your_json_string)print(person.name)  # Jason Argonaut
print(person.age)   # NoneYou can also serialize your object into a JSON string.person_json_string = person.to_json()Advanced usageJSON Argon also supports:Nested objectsLists and DictionariesJSON-Python names remappingFieldsEach field annotation support these parameters:<field>(type: Any, json_name: str = None)typeis a simple type likestr,int,floator a Classjson_nameis anoptionalstring representing the corresponding name in JSONFieldMeaningJSONRequiredA required, simple attribute"name": "Jason"NullableA nullable (None) simple attributeAs above, or"name": nullor no attribute at allRequiredListA required (but maybe empty) list of objects of the specifiedtype"names": ["Argo", "Atalanta"], or"names": []or"crew": [{"name": "Argo"}, {"name": "Atalanta"}]NullableListA nullable list of objects of the specifiedtypeAs above, or"names": nullor no attribute at allRequiredStringDictA required (but maybe empty) dict of string -> objects of the specifiedtype"tags": {"scope": "dev"}, or"tags": {}or"documents": {"name": {"length":12}}NullableStringDictA required (but maybe empty) list of objects of the specifiedtypeAs above, or"tags": nullor no attribute at allYou can find a complete example here (with the JSON below):from jsonargon.decorators import jsonclass
from jsonargon.fields.simple import Required, Nullable
from jsonargon.fields.dict import RequiredStringDict
from jsonargon.fields.list import RequiredList

@jsonclass
class Size:
    
    length: Required(float)
    width:  Required(float)
    height: Nullable(float, "heigth")  # Correct a JSON typo


@jsonclass
class Member:

    name: Required(str)
    role: Nullable(str)
    

@jsonclass
class Ship:
    
    name: Required(str, "shipName")
    size: Required(Size)
    crew: RequiredList(Member, "members")
    attributes: RequiredStringDict(str)To remap:{
    "shipName": "Argo",
    "size": {
        "width": 45.4,
        "length": 34.2
    },
    "members": [
        {
            "name": "Atalanta"
        },
        {   
            "name": "Jason",
            "role": "leader"
        }
    ]
    "attributes": {
        "rarity": "mythological",
        "status": "destroyed"
    }
}Origin of the nameThere are several reasons behind the name of this library.First of all, in Greek mythology, Jason was the leader of Argonauts.Jason is quite similar to JSON pronunciation. He was the hero who defeated the monstrous dragon (often depicted as a giant snake - a clear reference to Python) that guarded the Golden Fleece.Also, his ship was Argo, and the Argonauts his crew.Argon, instead, is a noble gas. And with the same Class and style of a noble, this library aims to make you write a much cleaner code when dealing with JSON.Make Jason proud of your code and join his crew of Argonauts.