I am tring to create a json file with my lists in my python code:
I have
arr_of_id_by_user = [1, 2, 3]
arr_of_wallet_amount = [100,3400,200]
I would like this to return in the json file like
jsonfile = [{
"user" : 1,
"wallet amount": 100
},
{
"user" : 2,
"wallet amount": 3400
},
{
"user" : 3,
"wallet amount": 200
}]
Is it possible to do that? I tried to do a for
loop like this:
for elements in arr_of_id_by_user:
return jsonify({
"id": elements
})
and json.dumps()
but it don't work ...
maybe I have to do a tuple with (user.value[0], wallet_amount.value[0])
?
for peoples who try to do the reverse thing : How to create a Python list from a JSON object?
I would like to thank all those who helped me and who participate in the learning of all.