Update webpagetool.php

This commit is contained in:
Namhyeon Go 2018-06-01 21:34:59 +09:00 committed by GitHub
parent cc0b767020
commit 01ebdcfc29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -378,3 +378,21 @@ if(!function_exists("get_web_xml")) {
return $result;
}
}
// 2016-06-01: Adaptive JSON is always quotes without escape non-ascii characters
if(!function_exists("get_adaptive_json")) {
function get_adaptive_json($data) {
$result = "";
$lines = array();
foreach($data as $k=>$v) {
if(is_array($v)) {
$lines[] = sprintf("\"%s\":%s", addslashes($k), get_adaptive_json($v));
} else {
$lines[] = sprintf("\"%s\":\"%s\"", addslashes($k), addslashes($v));
}
}
$result = "{" . implode(",", $lines) . "}";
return $result;
}
}