ThinkPHP5 cannot parse the received json datadata error

When ThinkPHP receives the JSON data sent by the front end, it uses the json_decodeparsed data null.

Reason: ThinkPHP will filter the received data by default, so after the JSON [string] is filtered, an error occurs.

Solution: Use the following methods to receive data, raw data (unfiltered)

// Get all variables of the current request (raw data) 
Request::instance()->param( false );
 // Get all get variables (original array) 
Request::instance()->get( false );
 / / Get all the original post variables 
Request::instance()->post( false );

Then you can json_decodeparse the json string again.

Leave a Comment

Your email address will not be published. Required fields are marked *