public function validate()
{
parent::validate('result');
$result = $this->getResult();
if (!is_string($result)) {
throw new InvalidRequestException('The result should be string');
}
if (substr($result, 0, 3) == '{\\"') {
$result = stripslashes($result);
}
$data = json_decode($result, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new InvalidRequestException('The result should be a valid json string');
}
if (!isset($data[$this->key])) {
throw new InvalidRequestException("The result decode data should contain {$this->key}");
}
}