21,886
社区成员
发帖
与我相关
我的任务
分享
function escapeUnicode(str) {
return str.replace(/[^ -~]|\\/g, function(m0) {
var code = m0.charCodeAt(0);
return '\\u' + ((code < 0x10)? '000' :
(code < 0x100)? '00' :
(code < 0x1000)? '0' : '') + code.toString(16);
});
}
function unescapeUnicode(str) {
return str.replace(/\\u([a-fA-F0-9]{4})/g, function(m0, m1) {
return String.fromCharCode(parseInt(m1, 16));
});
}
$output=$oJSON->encode($olost_person);
echo $output;
lost_person Object
(
[name] => 小张
[age] =>
[sex] => F
[latitude] => 30.25
[longitude] => 120.17
)
{"name":"\u0421\u0000","age":null,"sex":"F","latitude":"30.25","longitude":"120.17"}