japc 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
japc-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: japc
3
+ Version: 0.1.0
4
+ Summary: Automatically convert Python objects, sets, dates, and DataFrames to JSON.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ <p align="center">
9
+ <img src="https://github.com/mehliciouson/japc_python_library/blob/main/JAPC%20logo.png?raw=true" width="250">
10
+ </p>
11
+
12
+
13
+ Created by mehliciouson.
14
+
15
+ Welcome to japc, Json Automatic Python Converter.
16
+ To use this library after you have downloaded
17
+ and imported it, you'll need to master 4 functions
18
+ I implemented into the code. These are "tojson",
19
+ "savejson", "fromjson", and "loadjson". You can
20
+ find out more about these via this Google Doc: https://docs.google.com/document/d/14E4jTr07UtxhvLIZ3tHtVJQeehvZ0wchQuI2eznjGzY/edit?tab=t.0
21
+
22
+ Made with love on Pycharm :)
japc-0.1.0/README.md ADDED
@@ -0,0 +1,15 @@
1
+ <p align="center">
2
+ <img src="https://github.com/mehliciouson/japc_python_library/blob/main/JAPC%20logo.png?raw=true" width="250">
3
+ </p>
4
+
5
+
6
+ Created by mehliciouson.
7
+
8
+ Welcome to japc, Json Automatic Python Converter.
9
+ To use this library after you have downloaded
10
+ and imported it, you'll need to master 4 functions
11
+ I implemented into the code. These are "tojson",
12
+ "savejson", "fromjson", and "loadjson". You can
13
+ find out more about these via this Google Doc: https://docs.google.com/document/d/14E4jTr07UtxhvLIZ3tHtVJQeehvZ0wchQuI2eznjGzY/edit?tab=t.0
14
+
15
+ Made with love on Pycharm :)
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "japc"
7
+ version = "0.1.0"
8
+ description = "Automatically convert Python objects, sets, dates, and DataFrames to JSON."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
japc-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .core import tojson, savejson, fromjson, loadjson, autojson
@@ -0,0 +1,57 @@
1
+ import json
2
+ from datetime import datetime, date
3
+
4
+
5
+
6
+ def converter(obj):
7
+ #Pandas part
8
+ if hasattr(obj, "to_dict") and callable(obj.to_dict):
9
+ return obj.to_dict(orient="records")
10
+ #numpy part
11
+ if hasattr(obj, "item") and callable(obj.item):
12
+ return obj.item()
13
+
14
+ #custom classes
15
+ if hasattr(obj, "__dict__"):
16
+ return obj.__dict__
17
+
18
+ #sets and tuples
19
+ if isinstance(obj, (set, tuple)):
20
+ return list(obj)
21
+
22
+ #dates and timestamps
23
+ if isinstance(obj, (datetime, date)):
24
+ return obj.isoformat()
25
+
26
+ #fallback to text
27
+ return str(obj)
28
+
29
+ def tojson(anything, indent=4):
30
+ return json.dumps(anything,default=converter, indent=indent)
31
+
32
+ def savejson(anything, filename="output.json", indent=4):
33
+ with open(filename, "w") as f:
34
+ f.write(tojson(anything,indent=indent))
35
+
36
+ def fromjson(json_string):
37
+ return json.loads(json_string)
38
+
39
+ def loadjson(filename="output.json"):
40
+ with open(filename, "r") as f:
41
+ return json.load(f)
42
+
43
+ class autojson:
44
+ def tojson(self, indent=4):
45
+ return tojson(self, indent=indent)
46
+
47
+ def savejson(self, filename="output.json", indent=4):
48
+ savejson(self, filename,indent=indent)
49
+
50
+ @classmethod
51
+ def fromjson(cls, json_string):
52
+ data = fromjson(json_string)
53
+ return cls(**data)
54
+ @classmethod
55
+ def loadjson(cls, filename="output.json"):
56
+ data = loadjson(filename)
57
+ return cls(**data)
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: japc
3
+ Version: 0.1.0
4
+ Summary: Automatically convert Python objects, sets, dates, and DataFrames to JSON.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ <p align="center">
9
+ <img src="https://github.com/mehliciouson/japc_python_library/blob/main/JAPC%20logo.png?raw=true" width="250">
10
+ </p>
11
+
12
+
13
+ Created by mehliciouson.
14
+
15
+ Welcome to japc, Json Automatic Python Converter.
16
+ To use this library after you have downloaded
17
+ and imported it, you'll need to master 4 functions
18
+ I implemented into the code. These are "tojson",
19
+ "savejson", "fromjson", and "loadjson". You can
20
+ find out more about these via this Google Doc: https://docs.google.com/document/d/14E4jTr07UtxhvLIZ3tHtVJQeehvZ0wchQuI2eznjGzY/edit?tab=t.0
21
+
22
+ Made with love on Pycharm :)
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/japc/__init__.py
4
+ src/japc/core.py
5
+ src/japc.egg-info/PKG-INFO
6
+ src/japc.egg-info/SOURCES.txt
7
+ src/japc.egg-info/dependency_links.txt
8
+ src/japc.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ japc