PHP

json_decode — JSON 문자열 디코드

json_decode — JSON 문자열 디코드


mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 ]] )


JSON 인코드 문자열을 받아서 PHP 변수로 변환합니다.


두번째 인자로 TRUE를 주면 array로 반환.



[예 1]


$adma = '{"header":{"result":"success","code":"0000"},"body":{}}';


$value = json_decode($adma, true);


echo $value['header']['result'];


//success



[예 2]


$input = file_get_contents('php://input', 1000000); 

$value = json_decode($input); 


echo $value->partner;