Answer the question
In order to leave comments, you need to log in
How to write json to file while keeping unicode characters on node js?
Wrote on LAN (Windows 8.1) saves the file with all characters. After the transfer to the hosting (Centos 7) I began to save with "crakozyabry"
Code:
function updatePrice(body, startTimer){
var items = JSON.parse(fs.readFileSync('items.json', 'utf8'));
for (index = 0; index < body.items.length; ++index) {
var price = body.items[index].price;
var name = body.items[index].name;
var idItem = find(items, name);
if(~idItem){
items[idItem].jar = price;
items[idItem].ujar = new Date();
}
}
var items = JSON.stringify(items,"",4);
fs.writeFileSync('prices.json', items);
var elapsed = new Date().getTime() - startTimer;
logger.trace("Обновлено "+index+" предметов");
logger.trace("Время выполнения: "+elapsed+" мс.\n");
}
StatTrak\u2122 AK-47 | Aquamarine Revenge (Battle-Scarred)
StatTrakâ„¢ AK-47 | Aquamarine Revenge (Factory New)
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