I'm trying to match a regex expression to the value of Id in a json file. My goal is to iterate over a bunch of json files in a directory and replace the value of the Id key with the regex match. The regex works well by itself when i try it on regex101, however when I run it again the json files on my computer i get a
Error: TypeError: expected string or bytes-like object
. Any and all help appreciated. import json import os import re rootdir = r'C:\\Users\\homersimpson\\jsondumps' for files in os.scandir(rootdir): with open(files, "r") as file: json_data = json.load(file) extracted = re.findall((r'.+?(?<=\$apples\$)'),json_data) print(something)