+
+ /**
+ * sends the request to router
+ *
+ * @param string $path
+ * @param mixed $fields
+ * @param string $cookie
+ * @param integer $count
+ * @return array
+ */
+ protected function sentRequest ($path, $fields, $cookie = false, $count = 0) {
+ $data = parent::sentRequest($path, $fields, $cookie, $count);
+ $header = $data['header'];
+ $body = $data['body'];
+
+ // fix invalid json
+ $body = preg_replace("/(\r\n)|(\r)/", "\n", $body);
+ $body = preg_replace('/\'/i', '"', $body);
+ $body = preg_replace("/\[\s+\]/i", '[ {} ]', $body);
+ $body = preg_replace("/},\s+]/", "}\n]", $body);
+
+ // decode json
+ if (strpos($path, '.json') !== false) {
+ $json = json_decode($body, true);
+
+ if (is_array($json)) {
+ $body = $json;
+ }
+ }
+
+ return array('header' => $header, 'body' => $body);
+ }