A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a node.js program to get files or directories of a directory in JSON format
Q:

Write a node.js program to get files or directories of a directory in JSON format

0

Write a node.js program to get files or directories of a directory in JSON format

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution

JSON (JavaScript Object Notation) is a lightweight, open standard, data-interchange format. It is easy to read and write for humans. It is used primarily to transmit data between web application and server. The given example asynchronously convert directory tree structure into a JavaScript object.

Install with NPM

npm install dir-to-json --save
var dirToJson = require('dir-to-json');
 
dirToJson( "./album", function( err, dirTree ){
    if( err ){
        throw err;
    }else{
        console.log( dirTree );
    }
});
 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now