Cant seem to create "good" json file with python -
so in have loop. everytime code loop gets executed, happens:
json_data.append({object_name : [string1, string2]})
so im creating alot of arrays, followed 2 values inside each array.
after this:
json_file = json.dumps(json_data) open('test.json', 'w') f: json.dump(json_file, f, ensure_ascii=false)
the problem output im getting following:
"[{\"cat\": [\"female\", \"fish\"]}, {\"pig\": [\"male\", \"carrots\"]}, {\"dog\": [\"male\", \"dogfood"]}]"
now think wrong because: starts double quotes, wich indicates string , not json. after in each object there's escape sequence instead of quotes. how can solve of this?
stop dumping twice. you're generating json, , encoding resultant string json.
Comments
Post a Comment