cancel
Showing results for 
Search instead for 
Did you mean: 

I want to create new file and append the data whenever new user register in my application.

Former Member
0 Kudos

I am using SAUI5 in SAP WEB IDE and want to create new JSON file and append the data whenever new user register in my application. I am able to read the JSON file but need to write the data and file. Can any one help me for the same?

Accepted Solutions (1)

Accepted Solutions (1)

Sharathmg
Active Contributor
0 Kudos

Why are you trying to add it to file instead of creating it in a JSON object? If it's to store it permanently, it's not the best option.

Still, if you need to, then you can always get the file and then manually push content by structuring it.

Check this snippet relevant to you:

fs.readFile('myjsonfile.json', 'utf8', function readFileCallback(err, data){
    if (err){
        console.log(err);
    } else {
    obj = JSON.parse(data); //now it an object
    obj.table.push({id: 2, square:3}); //add some data
    json = JSON.stringify(obj); //convert it back to json
    fs.writeFile('myjsonfile.json', json, 'utf8', callback); // write it back 
}}); 
Former Member
0 Kudos

Thanks for your response. Sorry that I am responding very much late.

Actually I am using trial account, and could not able to connect to database. But now I have got the way by calling web services built by me in PHP and MySQL.

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

no way.