protected function decodeJSON($jsonString) { if (!$jsonString) { BadRequest400::throwException('Body request is empty!'); } $json = json_decode($jsonString, true, 20, JSON_OBJECT_AS_ARRAY); if (json_last_error()) { BadRequest400::throwException('Request JSON data is invalid!'); } return $json; }
public static function parseJSONParams($name) { $params = self::getApp()->request->get($name); if (!$params) { return []; } $params = json_decode($params, true); if (json_last_error()) { BadRequest400::throwException("'{$name}' JSON data is invalid!"); } if (!is_array($params)) { BadRequest400::throwException("'{$name}' JSON should be object"); } return $params; }