Hi.
I need to merge two JSON file in one.
Does anyone have a solution for how to do this on Switch?
JSON merger
Re: JSON merger
Are the two JSONs each in a dataset? Are they in the same folder? As this in the "Node.js scripting" section, perhaps this is what you are looking for:
Code: Select all
let json1 = JSON.parse(fs.readFileSync(pathToFirstJSONFile).toString());
let json2 = JSON.parse(fs.readFileSync(pathToSecondJSONFile).toString());
let newJson = { obj1:json1, obj2:json2 };
//and if the new JSON has to be saved into a new file:
fs.writeFileSync(pathToNewJSON, JSON.stringify(newJson));
-
- Member
- Posts: 30
- Joined: Tue Mar 03, 2020 11:28 am
Re: JSON merger
Thank You Freddy. Thats it!