简体   繁体   English

使用html和javascript构建树/嵌套树视图

[英]building a tree/ nested tree view using html and javascript

I have the following JSON data. 我有以下JSON数据。 I would like to build a tree/ nested tree view using the following data. 我想使用以下数据构建树/嵌套树视图。

The desirable output would be as follows: 理想的输出如下:

["carbon.agents.vagrant-ubuntu-precise-64-a.avgUpdateTime", "carbon.agents.vagrant-ubuntu-precise-64-a.cache.overflow", "carbon.agents.vagrant-ubuntu-precise-64-a.cache.queries", "carbon.agents.vagrant-ubuntu-precise-64-a.cache.queues", "carbon.agents.vagrant-ubuntu-precise-64-a.cache.size", "carbon.agents.vagrant-ubuntu-precise-64-a.committedPoints", "carbon.agents.vagrant-ubuntu-precise-64-a.cpuUsage", "carbon.agents.vagrant-ubuntu-precise-64-a.creates", "carbon.agents.vagrant-ubuntu-precise-64-a.errors", "carbon.agents.vagrant-ubuntu-precise-64-a.memUsage", "carbon.agents.vagrant-ubuntu-precise-64-a.metricsReceived", "carbon.agents.vagrant-ubuntu-precise-64-a.pointsPerUpdate", "carbon.agents.vagrant-ubuntu-precise-64-a.updateOperations", "carbon.aggregator.vagrant-ubuntu-precise-64-a.aggregateDatapointsSent", "carbon.aggregator.vagrant-ubuntu-precise-64-a.allocatedBuffers", "carbon.aggregator.vagrant-ubuntu-precise-64-a.bufferedDatapoints", "carbon.aggregator.vagrant-ubuntu-precise-64-a.cpuUsage", "carbon.aggregator.vagrant-ubuntu-precise-64-a.memUsage", "carbon.aggregator.vagrant-ubuntu-precise-64-a.metricsReceived", "stats.gauges.echo_server.throughput", "stats.gauges.logstash.host.10.0.1.8.cpu", "stats.gauges.logstash.host.10.0.1.8.memory_free", "stats.gauges.logstash.host.10.0.1.8.memory_total", "stats.gauges.logstash.host.10.0.1.8.rx_byte", "stats.gauges.logstash.host.10.0.1.8.rx_packets", "stats.gauges.logstash.host.10.0.1.8.tx_byte", "stats.gauges.logstash.host.10.0.1.8.tx_packets", "stats.gauges.logstash.host.general.request_time", "stats.gauges.logstash.host.nginx-lb0.act_conns"]

I would like to achieve the following output: 我想实现以下输出: 在此输入图像描述

I am able to parse the json, How would we achieve the view as above using HTML and JS in particular the folder and nested folder tree view? 我能够解析json,我们如何使用HTML和JS实现上面的视图,特别是文件夹和嵌套文件夹树视图?

Thanks 谢谢

There's an online tool to do that. 有一个在线工具可以做到这一点。 http://jsontree.com/ . http://jsontree.com/ You can try this to visualize you json data. 您可以尝试这样来显示您的json数据。

Also since you are interested in implementing a html/js solution. 此外,因为您有兴趣实现html / js解决方案。 Try jsTree jquery plugin. 试试jsTree jquery插件。

You can use this tool http://codedestine.com/json-editor.html to visualize your json. 您可以使用此工具http://codedestine.com/json-editor.html来可视化您的json。 It has many more features to edit and create json. 它还有许多功能可以编辑和创建json。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM