Skip to content

Instantly share code, notes, and snippets.



Last active Apr 11, 2019
What would you like to do?
@stcgoal Optimal Management of JSON Files
"name": "transapp",
"version": "0.0.1",
"description": "Master the Translate API to create. string Hello world is adde to each lang located in the i18n directory using the translator",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"keywords": [],
"author": "Guillaume Isabelle",
"license": "ISC",
"dependencies": {
"@exponent/json-file": "^5.3.0",
"@google-cloud/translate": "^3.0.1"
var JsonFile = require('@exponent/json-file');
//@stcgoal Optimal management of JSON file
//reads the JSON file
var file = new JsonFile('dummy.json', {cantReadFileDefault: {}});
//Read the File
//Adding new keys and value to the json file
obj.mynewkey = "something";
obj.mynewroot = new Object();
obj.mynewroot.myval = "a new subchild";
//@STCAction Show up each keys
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var v = obj[keys[i]];
//@STCgoal Writes the new JSON file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment