utils/create_url_polemics_param.py
author cavaliet
Fri, 17 Oct 2014 16:51:48 +0200
changeset 37 2d0e6a207048
child 38 dfb5081e8ebe
permissions -rwxr-xr-x
convert categories.json into url parameter for embed iframe colorisation

# 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"] })

print "SIMPLE JSON DUMPS :"
print json.dumps(output)
print "\nURLLIB QUOTE_PLUS JSON DUMPS :"
print urllib.quote_plus(json.dumps(output))