public function FormatterJson::parseBody in RESTful 7.2
Parses the body string into the common format.
Parameters
string $body: The string sent from the consumer.
Return value
array The parsed object following the expected structure.
Throws
\Drupal\restful\Exception\ServerConfigurationException
\Drupal\restful\Exception\BadRequestException
Overrides Formatter::parseBody
File
- src/
Plugin/ formatter/ FormatterJson.php, line 209 - Contains \Drupal\restful\Plugin\formatter\FormatterJson.
Class
- FormatterJson
- Class FormatterHalJson.
Namespace
Drupal\restful\Plugin\formatterCode
public function parseBody($body) {
if (!($decoded_json = drupal_json_decode($body))) {
throw new BadRequestException(sprintf('Invalid JSON provided: %s.', $body));
}
return $decoded_json;
}