php编码
$data = array( "name" => "王建国", "age" => 23 ); echo json_encode($data); // {"name":"\u738b\u5efa\u56fd","age":23} echo base64_encode(json_encode($data)); // eyJuYW1lIjoiXHU3MzhiXHU1ZWZhXHU1NmZkIiwiYWdlIjoyM30=
js解码
let str = '{"name":"\u738b\u5efa\u56fd","age":23}'; // 正常情况下可以反序列化 console.log(JSON.parse(str)); // { name: '王建国', age: 23 } // 可能有特殊字符不能解析,可以使用base64解码后再进行json解析 let enstr = "eyJuYW1lIjoiXHU3MzhiXHU1ZWZhXHU1NmZkIiwiYWdlIjoyM30="; console.log(JSON.parse(atob(enstr))); // {name: "王建国", age: 23}