Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
How do I browse directories for json files (JavaScript)?

I want to browse directories for json files and merge all json files into one json file per directory. My javascript skill is at beginner level.

The javascript code needs to run by calling it in the Terminal, not in the browser.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can make use of glob npm package to retrieve all json file paths in the directories.

glob : https://www.npmjs.com/package/glob

you can simply go with :

const glob = require("glob");
const fs = require('fs-extra');

async function processJsonData(){
  let parentDirectoryPath = '<specify path here>';
  let data = {};

  let jsonFilePaths = glob.sync(`${parentDirectoryPath}/*/*.json`);
  //this will return paths for all the json files 

    for (const jsonFilePath of jsonFilePaths) {
        let content = await fs.readJsonSync(jsonFilePath);
        Object.assign(data,content);
    }

     await fs.writeJson(<filePath>, data, {spaces: 2});
    //here specify your file path
}

ps. I am a new contributor, might have misread the question.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda