でJSONオブジェクトを作成します。これはPythonで私のコードです私はこのようなPythonでJSONオブジェクトを作りたいのpython
{
"to":["admin"],
"content":{
"message":"everything",
"command":0,
"date":["tag1",...,"tagn"]
},
"time":"YYYYMMDDhhmmss"
}
:
import json
cont = [{"message":"everything","command":0,"data":["tag1","tag2"]}]
json_content = json.dumps(cont,sort_keys=False,indent=2)
print json_content
data = [{"to":("admin"),"content":json_content, "time":"YYYYMMDDhhmmss"}]
json_obj = json.dumps(data,sort_keys=False, indent =2)
print json_obj
しかし、私はこのような結果が得られます。
[
{
"content": "[\n {\n \"data\": [\n \"tag1\", \n \"tag2\"\n ], \n \"message\": \"everything\", \n \"command\": 0\n }\n]",
"to": "admin",
"time": "YYYYMMDDhhmmss"
}
]
誰かお手伝いできますか?ありがとう
の可能性のある重複した[動的Pythonの持つJSONオブジェクトを構築する方法?](http://stackoverflow.com/questions/23110383/how-to-dynamically-build-a- json-object-with-python) – abhishek