Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to modify external json file javascript

//All Other code has an error 
//Here is the correct one
fs = require('fs');
var name = 'fileName.json';
var m = JSON.parse(fs.readFileSync(name).toString());
for(const p in m){
    p.name= m.name;
}
fs.writeFileSync(name, JSON.stringify(m));
Comment

edit external json file in javascript

fs = require('fs');
var name = 'fileName.json';
var m = JSON.parse(fs.readFileSync(name).toString());
m.forEach(function(p){
    p.name= m.name;
});
fs.writeFileSync(name, JSON.stringify(m));
Comment

js read external json file js

fs = require('fs');
var name = 'myFile.json';
var m = JSON.parse(fs.readFileSync(name).toString());
m.forEach(function(p){
    p.name= m.name;
});
fs.writeFileSync(name, JSON.stringify(m));
Comment

PREVIOUS NEXT
Code Example
Javascript :: share to gmail from website 
Javascript :: canvas text gradient 
Javascript :: express referrer 
Javascript :: JavaScript Display Objects 
Javascript :: use js to get select value 
Javascript :: months js 
Javascript :: xlsx js 
Javascript :: fibonacci series with recursion in javascript 
Javascript :: regular expression in elastic 
Javascript :: split first character of string in javascript 
Javascript :: storage package npm react 
Javascript :: send sms using twilio in node 
Javascript :: js while continue 
Javascript :: get server side props 
Javascript :: DatabaseError [SequelizeDatabaseError]: relation does not exist 
Javascript :: javascript insert div into another div 
Javascript :: check if value is number 
Javascript :: jquery document ready shorthand 
Javascript :: window.scrollTo Id sample code 
Javascript :: how to run and clone react app 
Javascript :: cors problem node js 
Javascript :: javascript filter 
Javascript :: antd tag 
Javascript :: export e import javascript 
Javascript :: bootstrap searchable pagination table example jquery 
Javascript :: Key Type 
Javascript :: vuex getters 
Javascript :: jquery once 
Javascript :: javascript super 
Javascript :: js remove all except numbers 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =