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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -