I have a JSON file in which I read objects and display them in a div. But I just need to show only five objects, not all.
Below is the code I'm using
$.each(recentActdata.slice(0,5), function(i, data) { var ul_data = "<li><h3>"+ renderActionLink(data)+ "</h3></li>"; $("#recentActivities").append(ul_data); });
But this fragment does not work. The format of my JSON is
[ { "displayValue":"Updated Guidelines", "link":"#", "timestamp":"29/06/2013 01:32" }, { "displayValue":"Logging", "link":"#", "timestamp":"28/06/2013 16:19" }, { "displayValue":"Subscribe", "link":"#", "timestamp":"21/06/2013 14:30" }, { "displayValue":"Artifactory Vs Nexus", "link":"#", "timestamp":"21/06/2013 13:39" }, { "displayValue":"CTT - Java 7", "link":"#", "timestamp":"20/06/2013 13:30" }, { "displayValue":"Added Artifactory Server", "link":"#", "timestamp":"19/06/2013 23:39" }, { "displayValue":"Estimation Template", "link":"#", "timestamp":"19/06/2013 23:39" }, { "displayValue":"GZIP compression in Tomcat", "link":"#", "timestamp":"14/06/2013 23:39" }, { "displayValue":"HBase Basics", "link":"#", "timestamp":"12/06/2013 23:39" } ]
Please suggest how to achieve this. I can not give my name JSON.
roger_that
source share