sorted json

parent b6d7b956
...@@ -8,6 +8,7 @@ import sys ...@@ -8,6 +8,7 @@ import sys
import os import os
import json import json
from collections import Counter from collections import Counter
#from collections import OrderedDict
########### lee archivo de configuración ################ ########### lee archivo de configuración ################
dirname = os.path.dirname(__file__) dirname = os.path.dirname(__file__)
...@@ -53,7 +54,7 @@ def main(argv): ...@@ -53,7 +54,7 @@ def main(argv):
jsonFile=open(argv[2]).read() jsonFile=open(argv[2]).read()
cfg = json.loads(jsonFile) cfg = json.loads(jsonFile)
dataDict = L2ASCLtoDict(argv[1], cfg['wkt']) dataDict = L2ASCLtoDict(argv[1], cfg['wkt'])
print(json.dumps(dataDict)) print(json.dumps(dataDict, sort_keys=True))
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv) main(sys.argv)
...@@ -23,7 +23,7 @@ def main(argv): ...@@ -23,7 +23,7 @@ def main(argv):
json_data['date']=f[:f.find("_")] json_data['date']=f[:f.find("_")]
jsonList.append(json_data) jsonList.append(json_data)
# print(json_data) # print(json_data)
print(json.dumps({i['date']: i for i in jsonList})) print(json.dumps({i['date']: i for i in jsonList}, sort_keys=True))
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment