import json print('********** JSON **********') data = dict() data['message'] = 'Python json test' data['members'] = [ {'name': 'momo', 'color': '#FA3E05' }, {'name': 'dubai', 'color': '#FFFFAA'} ] print(json.dumps(data, ensure_ascii=False, indent=2))
$ python3 app.py
********** JSON **********
{
“message”: “Python json test”,
“members”: [
{
“name”: “momo”,
“color”: “#FA3E05”
},
{
“name”: “dubai”,
“color”: “#FFFFAA”
}
]
}
json.dumpsで出力できる
問題ありませんね