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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -