docs: 批量博文

This commit is contained in:
杭城小刘
2020-02-25 17:46:51 +08:00
parent 8e5d2c9e7f
commit 6e99436a9e
373 changed files with 18071 additions and 1116 deletions

View File

@@ -0,0 +1,28 @@
# JSON的一些骚操作
* 将json转换为对象JSON.parse\(\)函数的第二个参数用来转换解析出的属性
```
JSON.parse('{"name":"lbp","age":"20"}',function(key,value){
if(key == "name"){
return value + "同学";
}
return value;
});
```
* 将对象转换为jsonJSON.stringify\(\)函数的第二个参数用来筛选对象的键值
```
var student = {"name":"小米","age":22,"height":177,"skills":["js","oc"]};
function convert(key,value){
if (typeof value === "string") {
return value.toString().toUpperCase();
}
return value;
}
JSON.stringify(student,convert,' ');
```