标签:bsp return 解码 decode nbsp base64 contex string 字符串
1. JSON对象转化为字符串
let obj = {
"name":Ayinger;
"sex":"女";
}
let str = JSON.stringify(obj);
//结果:str = " { "name" : "Ayinger" , "sex" : "女" } ";
2. 字符串转换为JSON对象
let obj1 = JSON.parse(str);
// 结果:obj1 = { name:"Ayinger" , sex:"女" };
3. 字符串转换为base64 (编码)
base64encoder(Context):any{
let encoder = new Buffer(Context).toString(‘base64‘);
return encoder;
}
4. base64换为 字符串转(解码)
base64decoder(Context):any{
let decoder = new Buffer(Context,‘base64‘).toString();
return decoder;
}
angular2 ----字符串、对象、base64 之间的转换
标签:bsp return 解码 decode nbsp base64 contex string 字符串
原文地址:http://www.cnblogs.com/Ayinger/p/7906801.html