php json_encode/json_decode mixed object and array output


php json_encode/json_decode mixed object and array output

{"data":[]} 를 script로 보내면 array이기 때문에 key : value 의 형태로 값을 넣을 수 없다. 또한 {"data":{}}로 되어 있더라도 json_decode를 하면 []로 변경된다. json_encode(변수, JSON_FORCE_OBJECT) 를 하게 되면 무조건 {} 로 변경되기 때문에 문제가 발생할 수 있다. (array를 사용해야 할 경우) if(count(변수) == 0) { 변수 = new stdClass(); } 와 같이 처리할 수 있다....

php json_encode/json_decode mixed object and array output에 대한 요약내용입니다.

자세한 내용은 아래에 원문링크를 확인해주시기 바랍니다.


#IT·컴퓨터

원문링크 : php json_encode/json_decode mixed object and array output