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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: partialjson
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: Parse incomplete or partial json
5
5
  Home-page: https://github.com/iw4p/partialjson
6
6
  Author: Nima Akbarzadeh
@@ -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.6"
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.endswith('.') or num_str.endswith('-'):
123
- return num_str, "" # Return the incomplete number as is
122
+ if not num_str or num_str == "-" or num_str == ".":
123
+ return num_str, ""
124
124
  try:
125
- num = float(num_str) if '.' in num_str or 'e' in num_str or 'E' in num_str else int(num_str)
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: partialjson
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: Parse incomplete or partial json
5
5
  Home-page: https://github.com/iw4p/partialjson
6
6
  Author: Nima Akbarzadeh
File without changes
File without changes
File without changes
File without changes