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; }