- Your task:
Display JSON-data in the browser in a table which is sortable by the user. - Solution:
Install JCI-Plugin and the plugin “Table Sorter“ - Example-Code:
original JSON: https://api.blockchain.info/charts/transactions-per-second?timespan=5weeks&rollingAverage=8hours&format=json
locally stored: http://api.json-content-importer.com/extra/json/api.blockchain.info.json[jsoncontentimporterpro url=https://api.blockchain.info/charts/transactions-per-second?timespan=5weeks&rollingAverage=8hours&format=json method=rawget parser=twig] {{description}} <table id="myTable" class="tablesorter">
<thead><tr>
<th>no (sortable)</th>
<th class="sortless">x</th>
<th>x (sortable)</th>
<th>y (sortable)</th>
<th>randomno (sortable) </tr></thead>
<tbody>
{%for v in values %}
{% if loop.index<10 %}
<tr><td>{{loop.index}}</td><td>{{v.x}}</td><td>{{v.x}}</td><td>{{v.y}}</td><td>
{{ random(5000) }} </td></tr>
{% endif %}
{% endfor %}
</tbody></table>
[/jsoncontentimporterpro]
The number of Bitcoin transactions added to the mempool per second.
no (sortable) | x | x (sortable) | y (sortable) | randomno (sortable) |
---|---|---|---|---|
1 | 1593550800 | 1593550800 | 4.45520833333 | 4840 |
2 | 1593552600 | 1593552600 | 4.396875 | 3102 |
3 | 1593554400 | 1593554400 | 4.32447916667 | 3455 |
4 | 1593556200 | 1593556200 | 4.24791666667 | 1518 |
5 | 1593558000 | 1593558000 | 4.1171875 | 490 |
6 | 1593559800 | 1593559800 | 4.00260416667 | 4644 |
7 | 1593561600 | 1593561600 | 3.8921875 | 4497 |
8 | 1593563400 | 1593563400 | 3.75677083333 | 4185 |
9 | 1593565200 | 1593565200 | 3.63541666667 | 3705 |
Credits: Thank you Lawrence from South Melbourne, Australia