Friday 5 May 2017

Add a root element to json

I have that code:

    let result = JSON.parse(json);
    let schema = fs.readFileSync(path, {encoding: 'utf8'});

    result.def = JSON.parse(schema); //add root here    
    fs.writeFile(`myJson.json`, JSON.stringify(result, null, 2));

I want to add a root to schema json. How would you do that?



via sreginogemoh

No comments:

Post a Comment