import json
import re

from src.system_var.constants import EXCLUDE_SYMBOL


class JsonParser():
    def __init__(self, json_str) -> None:
        self.__json_str = json_str

    def parse(self) -> dict:
        for symbol in EXCLUDE_SYMBOL:
            # コメントアウトシンボルを含む部分を置き換える正規表現
            replace_comment_regex = rf'\s(?!\"){symbol}[\s\S]*?.*'
            self.__json_str = re.sub(replace_comment_regex, '', self.__json_str)

        return json.loads(self.__json_str)
