partialjson 0.0.6__tar.gz → 0.0.7__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.
- {partialjson-0.0.6 → partialjson-0.0.7}/PKG-INFO +1 -1
- {partialjson-0.0.6 → partialjson-0.0.7}/partialjson/__init__.py +1 -1
- {partialjson-0.0.6 → partialjson-0.0.7}/partialjson/json_parser.py +6 -3
- {partialjson-0.0.6 → partialjson-0.0.7}/partialjson.egg-info/PKG-INFO +1 -1
- {partialjson-0.0.6 → partialjson-0.0.7}/LICENSE +0 -0
- {partialjson-0.0.6 → partialjson-0.0.7}/README.md +0 -0
- {partialjson-0.0.6 → partialjson-0.0.7}/partialjson.egg-info/SOURCES.txt +0 -0
- {partialjson-0.0.6 → partialjson-0.0.7}/partialjson.egg-info/dependency_links.txt +0 -0
- {partialjson-0.0.6 → partialjson-0.0.7}/partialjson.egg-info/top_level.txt +0 -0
- {partialjson-0.0.6 → partialjson-0.0.7}/setup.cfg +0 -0
- {partialjson-0.0.6 → partialjson-0.0.7}/setup.py +0 -0
|
@@ -5,7 +5,7 @@ Parsing ChatGPT JSON stream response — Partial and incomplete JSON parser pyth
|
|
|
5
5
|
"""
|
|
6
6
|
from .json_parser import JSONParser
|
|
7
7
|
|
|
8
|
-
__version__ = "0.0.
|
|
8
|
+
__version__ = "0.0.7"
|
|
9
9
|
__author__ = 'Nima Akbarzadeh'
|
|
10
10
|
__author_email__ = "iw4p@protonmail.com"
|
|
11
11
|
__license__ = "MIT"
|
|
@@ -119,10 +119,13 @@ class JSONParser:
|
|
|
119
119
|
i += 1
|
|
120
120
|
num_str = s[:i]
|
|
121
121
|
s = s[i:]
|
|
122
|
-
if not num_str or num_str
|
|
123
|
-
return num_str, ""
|
|
122
|
+
if not num_str or num_str == "-" or num_str == ".":
|
|
123
|
+
return num_str, ""
|
|
124
124
|
try:
|
|
125
|
-
|
|
125
|
+
if num_str.endswith('.'):
|
|
126
|
+
num = int(num_str[:-1])
|
|
127
|
+
else:
|
|
128
|
+
num = float(num_str) if '.' in num_str or 'e' in num_str or 'E' in num_str else int(num_str)
|
|
126
129
|
except ValueError:
|
|
127
130
|
raise e
|
|
128
131
|
return num, s
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|