Json对象替换字符串占位符实现代码

时间:2021-01-19 17:45:13
【文件属性】:
文件名称:Json对象替换字符串占位符实现代码
文件大小:19KB
文件格式:PDF
更新时间:2021-01-19 17:45:13
字符 字符串 对象 例如:   含有占位符的字符串hello,{name},your birthday is {birthday };   提供的Json对象{name: “czonechan”, birthday : “1989-07-02” } ;   替换后为 hello,czonechan,your birthday is 1989-07-02。 实现代码: 代码如下: Object.prototype.jsonToString=function(str) { o=this; return str.replace(/\{\w*\}/g, function (w) { r = w.substr(1,w.l

网友评论