public function WSDecoderJSON::decode in Web Service Data 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/WSDecoder/WSDecoderJSON.php \Drupal\wsdata\Plugin\WSDecoder\WSDecoderJSON::decode()
Decode the web service response string into an array.
Overrides WSDecoderBase::decode
File
- src/
Plugin/ WSDecoder/ WSDecoderJSON.php, line 21
Class
- WSDecoderJSON
- JSON Decoder.
Namespace
Drupal\wsdata\Plugin\WSDecoderCode
public function decode($data) {
if (!isset($data) || empty($data)) {
return;
}
// Remove UTF-8 BOM if present, json_decode() does not like it.
if (substr($data, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
$data = substr($data, 3);
}
$data = trim($data);
return Json::decode($data);
}