我有一个 JSON 文件:example_json.json,该文件如下所示:
{
"timeline":
{
"headline":"WELCOME",
"type":"default",
"text":"People say stuff",
"startDate":"10/4/2011 15:02:00",
"date": [
{
"startDate":"10/4/2011 15:10:00",
"endDate":"10/4/2011 15:55:00",
"headline":"prvo",
"text":"<p>dddddddddddddddd dd</p>",
"asset":
{
"caption":"yessss"
}
},
{
"startDate":"10/4/2011 17:02:00",
"endDate":"10/4/2011 18:02:00",
"headline":"drugo da da",
"text":"<p>In true political fashion, his character rattles off common jargon heard from people running for office.</p>",
"asset":
{
"media":"http://youtu.be/u4XpeU9erbg",
"credit":"",
"caption":""
}
}
]
}
}
所以这是 json 文件的示例。
另一方面,我有这个变量:
var place.name;
var zajson;
和:<button>Add to timeline</button>
现在我希望当我单击“添加到时间线”按钮时在“日期”内创建新的“元素”,“开始日期”为:curentDateFormat 格式为月/日/年 + zajson
并添加“标题”:place.name
如何添加这些变量并在 example_json.json 的“日期”内创建新元素?