json-repair 0.21.0__py3-none-any.whl → 0.22.0__py3-none-any.whl

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,7 +1,7 @@
1
1
  """
2
2
  This module will parse the JSON file following the BNF definition:
3
3
 
4
- <json> ::= <primitive> | <container>
4
+ <json> ::= <container>
5
5
 
6
6
  <primitive> ::= <number> | <string> | <boolean>
7
7
  ; Where:
@@ -98,6 +98,8 @@ class JSONParser:
98
98
  self,
99
99
  ) -> JSONReturnType:
100
100
  char = self.get_char_at()
101
+ # This parser will ignore any basic element (string or number) that is not inside an array or object
102
+ is_in_context = len(self.context) > 0
101
103
  # False means that we are at the end of the string provided, is the base case for recursion
102
104
  if char is False:
103
105
  return ""
@@ -120,10 +122,10 @@ class JSONParser:
120
122
  )
121
123
  return ""
122
124
  # <string> starts with a quote
123
- elif char in ['"', "'", "“"] or char.isalpha():
125
+ elif is_in_context and (char in ['"', "'", "“"] or char.isalpha()):
124
126
  return self.parse_string()
125
127
  # <number> starts with [0-9] or minus
126
- elif char.isdigit() or char == "-" or char == ".":
128
+ elif is_in_context and (char.isdigit() or char == "-" or char == "."):
127
129
  return self.parse_number()
128
130
  # If everything else fails, we just ignore and move on
129
131
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.21.0
3
+ Version: 0.22.0
4
4
  Summary: A package to repair broken json strings
5
5
  Author-email: Stefano Baccianella <4247706+mangiucugna@users.noreply.github.com>
6
6
  License: MIT License
@@ -0,0 +1,7 @@
1
+ json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
+ json_repair/json_repair.py,sha256=r3Vx2rhFwqL201vXB5hgiJR2zLll_Rx4cn1_xKnLSTo,27501
3
+ json_repair-0.22.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
+ json_repair-0.22.0.dist-info/METADATA,sha256=D8wdIzgpU3n8Wzwv9_qCsiNsi5410vq7ouOR7l9zke0,7333
5
+ json_repair-0.22.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ json_repair-0.22.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
+ json_repair-0.22.0.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
- json_repair/json_repair.py,sha256=ry94U3QoJwVgyG1qeQNEb8Qt8NtCLpCGR41GBA7tozY,27320
3
- json_repair-0.21.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
- json_repair-0.21.0.dist-info/METADATA,sha256=obBsHuNN7Ph5zX77VHmER2O9A61F3MXGBreEowdr-so,7333
5
- json_repair-0.21.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- json_repair-0.21.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
- json_repair-0.21.0.dist-info/RECORD,,