How is the right way to update an json file?

Json file is updated with a new change or just overwrited?

What kind of JSON file, for what purpose?

this for example maps.json:

{ 
"Map1": [ 
[1,1,1,1],  
[1,1,1,1],  
[1,1,1,1] 
]
}

them i want to put more maps in maps.json:

{ 
"Map1": [ 
[1,1,1,1],  
[1,1,1,1],  
[1,1,1,1] 
],
"Map2": [ 
[1,1,1,1],  
[1,1,1,1],  
[1,1,1,1] 
]
}

like that…

I use this:

var fileW = File.write("img/maps.json");                
//_dataBase, 0, _dataBase.length                
fileW.writeString(Json.stringify(list));                
fileW.close();

is this right? just overwrite the file…

Yeah, that should probably work, or if you need to, read in and parse the file first, then add to it, then write again.

It depends (ultimately) on whether anyone modifies the file but you – if it’s your output file, then it should be safe to overwrite it

When i add the new array is in string type or in dynamic type?