Files
2014-06-30 13:58:10 +02:00

25 lines
728 B
Python

__author__ = 'stubbfel'
import json
import glob
def readJSON(fileName):
with open(fileName, newline='\n') as jsonFile:
jsonObject = json.loads(jsonFile.read())
return jsonObject
def writeJSON(fileName, jsonObject):
with open(fileName, 'w', newline='\n') as jsonFile:
jsonFile.write(json.dumps(jsonObject, indent=4))
jsonFile.close()
def mergeJSON(files, outPutfileName):
mergeObject = {}
for fileName in files:
jsonObject = readJSON(fileName)
mergeObject[fileName] = jsonObject
writeJSON(outPutfileName, mergeObject)
#print (glob.glob("*.json"))
#result = readJSON("test.json")
#writeJSON("boo.json", result)
#mergeJSON(["test.json","boo.json"],"bla.json")