첩보를 join '|' 에서 json dict로 변경
This commit is contained in:
+15
-4
@@ -3,10 +3,11 @@ namespace sammo;
|
||||
|
||||
class Json
|
||||
{
|
||||
const PRETTY = 1;
|
||||
const DELETE_NULL = 2;
|
||||
const NO_CACHE = 4;
|
||||
const PASS_THROUGH = 8;
|
||||
const PRETTY = 1 << 0;
|
||||
const DELETE_NULL = 1 << 1;
|
||||
const NO_CACHE = 1 << 2;
|
||||
const PASS_THROUGH = 1 << 3;
|
||||
const EMPTY_ARRAY_IS_DICT = 1 << 4;
|
||||
|
||||
public static function encode($value, $flag = 0)
|
||||
{
|
||||
@@ -17,6 +18,10 @@ class Json
|
||||
if ($flag & static::DELETE_NULL) {
|
||||
$value = Util::eraseNullValue($value);
|
||||
}
|
||||
|
||||
if(($flag & static::EMPTY_ARRAY_IS_DICT) && $value === []){
|
||||
$value = (object)null;
|
||||
}
|
||||
return json_encode($value, $rawFlag);
|
||||
}
|
||||
|
||||
@@ -25,6 +30,12 @@ class Json
|
||||
return json_decode($value, true);
|
||||
}
|
||||
|
||||
public static function decodeObj($value){
|
||||
//NOTE: 구 코드가 모두 '배열'을 가정하기 때문에 decode는 연관배열로 반환하였으나,
|
||||
//호환을 위해서는object로 반환하는 것이 더 나을것
|
||||
return json_decode($value);
|
||||
}
|
||||
|
||||
public static function die($value, $flag = self::NO_CACHE)
|
||||
{
|
||||
//NOTE: REST 형식에 맞게, ok(), fail()로 쪼개는게 낫지 않을까 생각해봄.
|
||||
|
||||
@@ -160,6 +160,9 @@ class Util extends \utilphp\util
|
||||
if ($val == null) {
|
||||
return null;
|
||||
}
|
||||
if ($val == ''){
|
||||
return null;
|
||||
}
|
||||
return intval($val);
|
||||
}
|
||||
throw new \InvalidArgumentException('올바르지 않은 타입형 :'.$val);
|
||||
|
||||
Reference in New Issue
Block a user