我具有json格式的以下配置:
var obj = {"PUSH" : {"title" : "Medicines Packed - Bill Value {amount}", "body" : "We have packed your medicines. Your final bill value is Rs {amount} . We will shortly update you on the delivery boy details."}};
var myJSON = JSON.stringify(obj);
myJSON.replace("{amount}", "100");
我基本上有{amount}作为占位符,我正试图以上述方式在Node.js中替换它。但是占位符保持原样,并且不会进行替换。正确的方法是什么?
答案 0 :(得分:0)
您可以使用split and join
var obj = {
"PUSH": {
"title": "Medicines Packed - Bill Value {amount}",
"body": "We have packed your medicines. Your final bill value is Rs {amount} . We will shortly update you on the delivery boy details."
}
};
console.log(JSON.stringify(obj).split("{amount}").join("100"))