Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How do I get a JSON file to show sub-arrays?

I know it's a simple question, but I've tried multiple ways and I can't get it to work. I have a huge JSON file (that I use a reduced version of) which I finally managed to let my script retrieve the file using the require(); function:

let wordBank = './Wordbank.json';

function getData() {
  console.log(require(wordBank));
}
getData();

The terminal displays the few lines of my reduced JSON file like this, why?: Notice the green "Array"?

I haven't really been able to find any answer...

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use console.dir instead of console.log

console.dir(data, {depth:100})

Its having a depth parameter to expand json upto given level

about 4 years ago · Juan Pablo Isaza Report

0

You need to use JSON.stringify to convert the object to JSON string. So you need to change your code like this:

let wordBank = './Wordbank.json';
function getData() {
   console.log(JSON.stringify(require(wordBank)));
}
getData();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!