utils/create_url_polemics_param.py
changeset 37 2d0e6a207048
child 38 dfb5081e8ebe
equal deleted inserted replaced
36:5d392dea4f49 37:2d0e6a207048
       
     1 # yo
       
     2 import json
       
     3 import urllib
       
     4 
       
     5 path = "../client/data/categories.json"
       
     6 json_file=open(path)
       
     7 data = json.load(json_file)
       
     8 json_file.close()
       
     9 
       
    10 output = []
       
    11 
       
    12 for c in data["categories"]:
       
    13     if "subcategories" in c and len(c["subcategories"])>0:
       
    14         for sc in c["subcategories"]:
       
    15             output.append({"name": sc["code"],"keywords": [ sc["label"] ], "color" : sc["color"] })
       
    16     else:
       
    17         output.append({"name": c["code"],"keywords": [ c["label"] ], "color" : c["color"] })
       
    18 
       
    19 print "SIMPLE JSON DUMPS :"
       
    20 print json.dumps(output)
       
    21 print "\nURLLIB QUOTE_PLUS JSON DUMPS :"
       
    22 print urllib.quote_plus(json.dumps(output))