@@ -167,10 +167,10 @@ class ValidationError(Exception):
167
167
168
168
# Remove jsonc annotations
169
169
# Copied from https://github.com/NickolaiBeloguzov/jsonc-parser/blob/master/jsonc_parser/parser.py#L11-L39
170
- RE_JSONC = re .compile (r"(\".*?\ "|\'.*?\')|(/\*.*?\*/| //[^\r\n]*$)" , re .MULTILINE | re .DOTALL )
170
+ RE_JSONC = re .compile (r"(\".*?(?<!\\)\ "|\'.*?\')|(\s* /\*.*?\*/\s*|\s* //[^\r\n]*$)" , re .MULTILINE | re .DOTALL )
171
171
172
172
173
- def remove_jasonc (text : str ) -> str :
173
+ def remove_jsonc (text : str ) -> str :
174
174
""" Remove jsonc annotations """
175
175
def _re_sub (match : re .Match [str ]) -> str :
176
176
if match .group (2 ) is not None :
@@ -406,7 +406,7 @@ def generate_node(contents: str|TODJson) -> "Node":
406
406
if isinstance (contents , str ):
407
407
408
408
# Remove jsonc annotations
409
- jsontext = remove_jasonc (contents )
409
+ jsontext = remove_jsonc (contents )
410
410
411
411
# Load the json
412
412
jd : TODJson = json .loads (jsontext )
@@ -426,7 +426,7 @@ def generate_node(contents: str|TODJson) -> "Node":
426
426
global SCHEMA # pylint: disable=global-statement
427
427
if not SCHEMA :
428
428
with open (objdictgen .JSON_SCHEMA , 'r' , encoding = "utf-8" ) as f :
429
- SCHEMA = json .loads (remove_jasonc (f .read ()))
429
+ SCHEMA = json .loads (remove_jsonc (f .read ()))
430
430
431
431
if SCHEMA and jd .get ('$version' ) == JSON_VERSION :
432
432
jsonschema .validate (jd , schema = SCHEMA )
0 commit comments