I'm trying to output the results from my script to JSON. I'm no doubt missing something simple but I'm still learning python. I've imported json at the top of the script. Any pointers in the right direction appreciated.
top_k = results.argsort()[-5:][::-1]
labels = load_labels(label_file)
template = '"{}":"{:0.5f}"'
a=[]
for i in top_k:
a.append(template.format(labels[i], results[i]))
y = json.dumps(a)
print(y)
Current output is just one long array.