I need to parse the below json with jquery and display in a html table.
display the values of "key" and "doc_count" in a html table.
Help is appreciated. see json below:
{ "key": "A", "count": 100 }, { "key": "AB", "count": 800 }
I need to parse the below json with jquery and display in a html table.
display the values of "key" and "doc_count" in a html table.
Help is appreciated. see json below:
{ "key": "A", "count": 100 }, { "key": "AB", "count": 800 }
Try This code:
Use any Template Engine(Handlebars or Underscore) to process HTML. I am assuming data is in the form of Static Json.
Make a table and append to HTML page:
var Table=$("<table class='json_data'>");
$('body').append(Table);
Then iterate whole Json to get the desired value.Like this:
$.each(parse_json.aggregations[2].buckets,function(index,value){
$('.json_data').append("<tr><td>"+value.key+"</td><td>"+value.doc_count+"</td></tr>");
})
JSFiddle Link: https://jsfiddle.net/Dee0565/17u4xs3s/