Hi,
I am trying to use mustache.java to display json data in tabular format on console.
I am able to create html table using the below mustache template but I want the output to be a text/ascii table instead of an html table.
Mustache template:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Mark</th>
<th>Subject</th>
</tr>
</thead>
<tbody>
{{#students}}
<tr>
<td>{{name}}</td>
<td>{{mark}}</td>
<td>{{subject}}</td>
</tr>
{{/students}}
</tbody>
</table>
</body>
</html>
JSON data:
{
"students": [
{
"name": "sandeep1",
"mark": 35,
"subject": "Geography"
},
{
"name": "sangeeta",
"mark": 135,
"subject": "English"
},
{
"name": "surabhi",
"mark": 315,
"subject": "History"
},
{
"name": "sumanta",
"mark": 305,
"subject": "Mathematics"
},
{
"name": "Ram",
"mark": 352,
"subject": "History"
},
{
"name": "John",
"mark": 350,
"subject": "Geography"
},
{
"name": "Jack",
"mark": 355,
"subject": "English"
}
]}
Is there a way to display json data as a text table using mustache.java?
I have attached a sample format that I found online.