public function deserialize($json)
    {
        $data = json_decode($json, true);

        //catch JSON parsing error
        $error = RESTfulAPIError::get_json_error();
        if ($error !== false) {
            return new RESTfulAPIError(400, $error);
        }

        if ($data) {
            $data = $this->unformatPayloadData($data);
        } else {
            return new RESTfulAPIError(400,
                "No data received."
            );
        }

        return $data;
    }