Dan
Dan

Reputation: 536

Best practice when dealing with large JSON file

I have a JSON file with about 500 lines on it. I feel like dumping this JSON into the bottom of Node.JS file isn't best practice. What options are available?

Upvotes: 1

Views: 239

Answers (1)

Catalin MUNTEANU
Catalin MUNTEANU

Reputation: 5634

You should create a separate file with the JSON contents:

filename.json:

{
   .. json content
}

Then in your JS files require it:

var JSON_data = require('./filename.json');

// Access the data using JSON_data.property_name

Upvotes: 4

Related Questions