WSDecoderJSON.php in Web Service Data 2.0.x
File
src/Plugin/WSDecoder/WSDecoderJSON.php
View source
<?php
namespace Drupal\wsdata\Plugin\WSDecoder;
use Drupal\wsdata\Plugin\WSDecoderBase;
use Drupal\Component\Serialization\Json;
class WSDecoderJSON extends WSDecoderBase {
public function decode($data) {
if (!isset($data) || empty($data)) {
return;
}
if (substr($data, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
$data = substr($data, 3);
}
$data = trim($data);
return Json::decode($data);
}
public function accepts() {
return [
'text/json',
];
}
}