utils/create_url_polemics_param.py
author cavaliet
Fri, 17 Oct 2014 17:05:09 +0200
changeset 38 dfb5081e8ebe
parent 37 2d0e6a207048
child 39 c922bf9167aa
permissions -rwxr-xr-x
little correction

# yo
import json
import urllib

path = "../client/data/categories.json"
json_file=open(path)
data = json.load(json_file)
json_file.close()

output = []

for c in data["categories"]:
    if "subcategories" in c and len(c["subcategories"])>0:
        for sc in c["subcategories"]:
            output.append({"name": sc["code"],"keywords": [ sc["label"] ], "color" : sc["color"] })
    else:
        output.append({"name": c["code"],"keywords": [ c["label"] ], "color" : c["color"] })

output_str = json.dumps(output, separators=(',',':'))
print "SIMPLE JSON DUMPS :"
print output_str
print "\nURLLIB QUOTE_PLUS JSON DUMPS :"
print urllib.quote_plus(output_str)