Socket
Book a DemoInstallSign in
Socket

json-file-structure

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-file-structure

Clean and simple JavaScript project for turning JSON objects into directory and file structures.

1.0.11
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Getting started

"json-file-structure" was created to create file & directory structures from a JSON definition

Example

	const JSONtoFiles = require('json-file-structure);

	let destination = 'dist';

	let data = [
		{
			name: "index.html",  // required
			content: "<h1 id=\"header\">Home Page</h1>"
		},{
			name: "about.html",  // required
			content: "<h1 id=\"header\">About Page</h1>"
		},{
			name: "assets",  // required
			children: [ // required for directories
				{
					name: "projects.json", // required
					content: "{\"projects\":[]}"
				},
				{
					name: "images", // required
					children: [] // required for directories
				}
			]
		}
	]


	JSONtoFiles(destination,data);
Output
- dist/
	- index.html
	- about.html
	- assets/
		- projects.json
		- images/

Types

json-file-structure can create both directories and files. Below are the required fields for each.

Directories (folders)

Directories are created when an object has a children key with a value type of array. This array can be empty but it MUST exist for a directory to be created. You can nest directories

empty directory
{
	name: "images", // required
	children: [] // required
}

Files

Files are created if the object has a name. However content is optional.

empty file
{
	name: "test.txt", // required
}

Keywords

filesystem

FAQs

Package last updated on 11 Dec 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.