user3045352
user3045352

Reputation: 61

render json using jquery template

I have below Json output

{ "IDsInThisList":"28184,28181,28180,28178","RowsReturned":"4","List" :[{"ContentID":28184,"ArticleType":"News","Headline":"Mobile Bytes","Article":"<p>HTC CFO Chialin Chang expects the manufacturer&rsquo;s fortunes to change for the better going in to 2014.</p>"}]}

I need to get "Headline" out and display it using jquery template, i normally uses {{:Headline}} but for somereason its not working, possibly because its inside "List", how to i render "Headline" out?

Upvotes: 0

Views: 53

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115282

Parse the string using JSON.parse() then access using 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&rsquo;s fortunes to change for the better going in to 2014.</p>"}]}');

console.log(a.List[0].Headline);

Fiddle Demo

Upvotes: 3

Related Questions