Package: jsonwhatever
jsonwhateverjsonwhatever is a library that creates a string, just putting a name and the object as arguments.InstallationUse the package managerpipto install jsonwhatever.pipinstalljsonwhateverUsagefromjsonwhateverimportJsonWhatEverthisdict={"brand":"Ford","model":"Mustang","year":1964}classDog:def__init__(self)->None:self.id=0self.name='fido'self.size=5.3classPerson:def__init__(self,id,name,dog)->None:self.id=idself.name=nameself.dog=dogdog_a=Dog()complex_number=5+9jlist_b=[4,5,6,8]list_a=[2,3,'hello',7,list_b]list_c=[4,5,thisdict,8,complex_number]empty_list=[]none_var=Nonebool_var=Trueset_example_empty=set()set_example={1,2,3,4}class_example=Person(9,'john',dog_a)bytes_example=bytes(4)bytearray_example=bytearray(4)#########################jsonwe=JsonWhatEver()##########################prints {"list_example":[4,5,6,8]}print(jsonwe.jsonwhatever('list_example',list_b))#prints {"name":"john"}print(jsonwe.jsonwhatever('name','john'))#prints {"size":1.7}print(jsonwe.jsonwhatever('size',1.7))#prints {"empty_list":[]}print(jsonwe.jsonwhatever('empty_list',empty_list))#prints {"none_example":null}print(jsonwe.jsonwhatever('none_example',none_var))#prints {"boolean":True}print(jsonwe.jsonwhatever('boolean',bool_var))#prints {"empty_set":[]}print(jsonwe.jsonwhatever('empty_set',set_example_empty))#prints {"set_example":[1,2,3,4]}print(jsonwe.jsonwhatever('set_example',set_example))#prints {"brand":"Ford","model":"Mustang","year":1964}print(jsonwe.jsonwhatever('thisdict',thisdict))#prints {"id":9,"name":"juan",{"id":0,"name":"perro","size":5.3}}print(jsonwe.jsonwhatever('person_class',class_example))#prints {"bytes_example":"b'\x00\x00\x00\x00'"}print(jsonwe.jsonwhatever('bytes_example',bytes_example))#prints {"bytearray_example":"b'\x00\x00\x00\x00'"}print(jsonwe.jsonwhatever('bytearray_example',bytearray_example))#prints {"crazy_list":[4,5,{"brand":"Ford","model":"Mustang","year":1964},8,"(5+9j)"]}print(jsonwe.jsonwhatever('crazy_list',list_c))ContributingPull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.Please make sure to update tests as appropriate.Things to know aboutYou always have to put some name on the first argument of the jsonwhatever function, otherwise the function will return a string that does not match the json standard.The jsonwhatever function can allow recursivity on a list until the level 800, after that, it will rise the RecursionError exception.The jsonwhatever function allows you to recieve a json without the curly braces at the beginning and in the end of the phrase. By default it will be in True.#prints "name":"john"print(jsonwe.jsonwhatever('name','john',False))#prints {"name":"john"}print(jsonwe.jsonwhatever('name','john',True))print(jsonwe.jsonwhatever('name','john'))Release NotesThe main structure in the library is an object class.Now a few attributes are private, like the datatypes.The class can detect the ammount of levels of recursions.The maximum level of recursions are 800, after that it will raise a RecursionError exception.We fixed a bug in the recursion counter, that stops the recursion after the number 800.The Big O notation is O(n), but after 2 million items the behavior stops being linear.