Saturday 10 June 2017

Modify a JSON object between two files

I am developing a nodejs project and stuck at this problem. I have a empty JSON object in one file and will update this object value in secondfile.

jsonFile.js

var jsonObj = {



    first: []

    ,
    second: []


    ,
    third: [],
};


exports.jsonObj=jsonObj;

pushdata.js

 var obj= require('./jsonFile.js');
                // i'll retrieve data from file and push into the obj...
for the sake of simplicity im not writing data fetching code..

                ojb.jsonObj.first.push("user1");

How can I update this json object in pushdata.js file in such a way that it also updates/change the json object in jsonFile.js



via Alturistic

No comments:

Post a Comment