Re: POST, content-type: application/json and json_decode

From: Date: Tue, 25 Sep 2012 08:02:36 +0000
Subject: Re: POST, content-type: application/json and json_decode
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-63234@lists.php.net to get a copy of this message
On 24/09/12 20:09, Andrew Faulds wrote:
On 21/09/12 12:05, Ivan Enderlin @ Hoa wrote:
Hello, If PHP receives a HTTP request with the method POST and with the header Content-Type: application/x-www-form-encoded, then, it automatically parses the request body to populate an array in $_POST. If the Content-Type is different (e.g. text/plain or application/json), the request body is reachable by reading php://input. Well, it is ok. But is there any plans to consider application/json by parsing the request body and populate the result in $_POST (with the help of json_decode() maybe)?
I think perhaps that's the wrong approach. It's valid JSON to have a list literal at the top level as well, I think. Perhaps we should introduce a new $_JSON variable or some such thing? $_BODY? $_BODY === php://input.
-- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/

« previous php.internals (#63234) next »