0

How to write data in json file in JavaScript

All are saying it cannot be done. So how do all websites do this.

21st May 2021, 4:18 PM
Aman Kumar
Aman Kumar - avatar
4 Answers
+ 2
in web context, the only way is to use server sided script... to save json file at user side you must let user download (and save) it manually (you cannot force that for security reasons)... however, you could handle that way with user side script only, by providing the download to user through base64 encoded / blob conversion of the text file content (the json string)... but that's quite tricky (almost to do it working cross-browsers) ^^
21st May 2021, 4:25 PM
visph
visph - avatar
+ 1
And how do you do in apps. Want to save user details in json file. Using React
21st May 2021, 5:24 PM
Aman Kumar
Aman Kumar - avatar