我有Json输出
{ "IDsInThisList":"28184,28181,28180,28178","RowsReturned":"4","List" :[{"ContentID":28184,"ArticleType":"News","Headline":"Mobile Bytes","Article":"<p>HTC CFO Chialin Chang expects the manufacturer’s fortunes to change for the better going in to 2014.</p>"}]}
我需要获取“标题”并使用jquery模板显示它,我通常使用{{:Headline}}但是因为某些原因它不起作用,可能是因为它在里面“List”,如何渲染“标题” ?
答案 0 :(得分:3)
使用JSON.parse()
解析字符串,然后使用a.List[0].Headline
var a=JSON.parse('{ "IDsInThisList":"28184,28181,28180,28178","RowsReturned":"4","List" :[{"ContentID":28184,"ArticleType":"News","Headline":"Mobile Bytes","Article":"<p>HTC CFO Chialin Chang expects the manufacturer’s fortunes to change for the better going in to 2014.</p>"}]}');
console.log(a.List[0].Headline);