Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json2tree

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json2tree

Json to Tree Utility

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JSON to TREE

This project is a utility for configure a json and parse to ul/li tree.

Installation

npm install json2tree

JSON format

Sample of configure

[
  //Define a folder
  { "name": "Node Name",
    "type": "folder",
    "nodes":[
      //Define files or folder inside a folder
      {"type":"node","link":"http://www.google.com","name":"External link"},
      {"type":"node","link":"/test.html","name":"Internal link"},
      {"type":"node","link":"mailto:xxx@ooo.com","name":"mail link"},
      [
        "name": "Node Name",
        "type": "folder",
        "nodes":[
          ....
        ]
      ]
      ...
    ]
  },
  ...
]

Parse

var j2t = require('json2table');

var out = j2t.toUlTree(
  [
    { "name": "Level 1 Folder",
      "type": "folder",
      "nodes":[
        {"type":"node","link":"http://www.google.com","name":"node1"},
        {
          "name": "Level 2 Folder",
          "type": "folder",
          "nodes":[
            {"type":"node","link":"http://www.google.com","name":"node1.1"},
            {"type":"node","link":"http://www.google.com","name":"node1.2"}
          ]
        }
      ]
    }
  ]
);

console.log(out);

Output:

<ul id="browser" class="filetree"><span style="font-size:+1"></span><li><span class="folder">Level 1 Folder</span><ul> <li><span class="file"><a href="http://www.google.com">node1</a></span></li><li><span class="folder">Level 2 Folder</span><ul> <li><span class="file"><a href="http://www.google.com">node1.1</a></span></li><li><span class="file"><a href="http://www.google.com">node1.2</a></span></li></ul></li></ul></li></ul>

Page View:

See test.html

Keywords

FAQs

Package last updated on 12 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc