Duplicate of my question: How to read json folder data using Python?
Thanks to all answered the question
Duplicate of my question: How to read json folder data using Python?
Thanks to all answered the question
Just call json.load
with an opened file
import json
with open("package.json") as f:
data = json.load(f)
print(data)
To traverse folders you can use os.walkdir
, this should give you a template to start :)
import json
import sys
import os
def walkrec(root):
for root, dirs, files in os.walk(root):
for file in files:
path = os.path.join(root, file)
if file.endswith(".json"):
print(file, end=' ')
with open(path) as f:
data = json.load(f)
print(data)
if __name__ == '__main__':
walkrec(sys.argv[1])