public static function getJSONResponseToArray($string) {
    $json = json_decode($string,true);
    if($json !== NULL) {
      return $json;
    }
    else {
      throw new \Exception('Response is not a valid json string.');
    }
  }