You are here

wsdata_simple_json.wsdata.processor.inc in Web Service Data 7

File

wsdata_simple_json.wsdata.processor.inc
View source
<?php

class wsdata_simple_json_processor extends WsData {

  // Parse the web service response string, and returns a structured data array
  public function parse($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, TRUE);
  }
  function accepts() {
    return array(
      'json',
    );
  }

}

Classes