@@ -167,10 +167,10 @@ class ValidationError(Exception):
167167
168168# Remove jsonc annotations
169169# 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 )
171171
172172
173- def remove_jasonc (text : str ) -> str :
173+ def remove_jsonc (text : str ) -> str :
174174 """ Remove jsonc annotations """
175175 def _re_sub (match : re .Match [str ]) -> str :
176176 if match .group (2 ) is not None :
@@ -406,7 +406,7 @@ def generate_node(contents: str|TODJson) -> "Node":
406406 if isinstance (contents , str ):
407407
408408 # Remove jsonc annotations
409- jsontext = remove_jasonc (contents )
409+ jsontext = remove_jsonc (contents )
410410
411411 # Load the json
412412 jd : TODJson = json .loads (jsontext )
@@ -426,7 +426,7 @@ def generate_node(contents: str|TODJson) -> "Node":
426426 global SCHEMA # pylint: disable=global-statement
427427 if not SCHEMA :
428428 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 ()))
430430
431431 if SCHEMA and jd .get ('$version' ) == JSON_VERSION :
432432 jsonschema .validate (jd , schema = SCHEMA )
0 commit comments