Answer the question
In order to leave comments, you need to log in
How to write specific content to Json file?
Here is my code that displays the content of profi.json
And below is the content of Json The
question is how to display not all the contents, but only for example "shopperName": "Vanya Ivanov",
And write to another DATA.json file
And the question is different
How to read several JSON files and after not overwriting in DATA.json, namely adding to the same file
var fs = require('fs');
var file = __dirname + '/profi.json';
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.log('Error: ' + err);
return;
}
data = JSON.parse(data);
console.dir(data);
});
{
"orderID": 12345,
"shopperName": "Ваня Иванов",
"shopperEmail": "[email protected]",
"contents": [
{
"productID": 34,
"productName": "Супер товар",
"quantity": 1
},
{
"productID": 56,
"productName": "Чудо товар",
"quantity": 3
}
],
"orderCompleted": true
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question