Files
Mranalysis/json/jsonutility.py
stubbfel 5267f00fab 20140311
2014-03-11 15:13:43 +01: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")