How to select and add data in existing file using Node JS?

Can some body please explain , I have a large data in my json file and i have to select at some point like data === smp('Report').

smp( "Reports" ) {
            smp( "firewall_real_time" ) {
                smp( "Appearance Settings" ) {
                    int( "Alignlogo" ) = 1812531465
                    int( "Alignlogo2" ) = 980706917
                    str( "Alignment" ) = ""
                    int( "Diagram Background Color" ) = 16777215
                    smp( "Fonts" ) {
                        smp( "Copyright" ) {
                            int( "Size" ) = 10
                            int( "Width" ) = 300
                            int( "XAxis" ) = 500
                            int( "YAxis" ) = 50
                        }
                    }
// I have to add extra data here so please help me how to add in between { { } }.
                 }
              }

Thank you in advance!

This is pretty easy. I don't know your json file structure, but if you simply:

var data = require('./report.json');

Then "data" is just a regular JS object with all the same structure as in the file. So if it looks like

{ "reports" : [ { "firewall_status" : "on"}]}

Or something like that, then data could do :

console.log(data.reports[0].firewall_status); 

and it would print "on".

likewise, you could do something like

data.reports.push({firewall_status : "off"});

or whatever else you'd do with a plain old JS object.

When you're done, you'll probably want to write the data back to disk, so you would do so by stringifying the object and writing it out w/ the fs module:

fs.writeFile('./report.json', JSON.stringify(data, null, 4), function(err) {
    if(err) {
      console.log(err);
    } else {
      console.log('JSON saved');
    }
});