partialjson 0.0.5__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.5 → partialjson-0.0.7}/PKG-INFO +1 -1
- {partialjson-0.0.5 → partialjson-0.0.7}/partialjson/__init__.py +3 -3
- {partialjson-0.0.5 → partialjson-0.0.7}/partialjson/json_parser.py +9 -6
- {partialjson-0.0.5 → partialjson-0.0.7}/partialjson.egg-info/PKG-INFO +1 -1
- {partialjson-0.0.5 → partialjson-0.0.7}/LICENSE +0 -0
- {partialjson-0.0.5 → partialjson-0.0.7}/README.md +0 -0
- {partialjson-0.0.5 → partialjson-0.0.7}/partialjson.egg-info/SOURCES.txt +0 -0
- {partialjson-0.0.5 → partialjson-0.0.7}/partialjson.egg-info/dependency_links.txt +0 -0
- {partialjson-0.0.5 → partialjson-0.0.7}/partialjson.egg-info/top_level.txt +0 -0
- {partialjson-0.0.5 → partialjson-0.0.7}/setup.cfg +0 -0
- {partialjson-0.0.5 → partialjson-0.0.7}/setup.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Partial Json.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Parsing ChatGPT JSON stream response — Partial and incomplete JSON parser python library for OpenAI
|
|
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,26 +119,29 @@ 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
|
|
129
132
|
|
|
130
133
|
def parse_true(self, s, e):
|
|
131
|
-
if s.startswith('
|
|
134
|
+
if s.startswith('t') or s.startswith('T'):
|
|
132
135
|
return True, s[4:]
|
|
133
136
|
raise e
|
|
134
137
|
|
|
135
138
|
def parse_false(self, s, e):
|
|
136
|
-
if s.startswith('
|
|
139
|
+
if s.startswith('f') or s.startswith('F'):
|
|
137
140
|
return False, s[5:]
|
|
138
141
|
raise e
|
|
139
142
|
|
|
140
143
|
def parse_null(self, s, e):
|
|
141
|
-
if s.startswith('
|
|
144
|
+
if s.startswith('n'):
|
|
142
145
|
return None, s[4:]
|
|
143
146
|
raise e
|
|
144
147
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|