<?php

class GPURIControllerHandler extends GPControllerHandler {

  public function handle($method, array $args) {
    $index = GPConfig::get()->use_index_php ? '/index.php' : '';
    return $index.'/'.strtolower($this->controller).'/'.$method.
      ($args ? '/'.implode('/', $args) : '');
  }

  public function __toString() {
    return $this->handle('', []);
  }

}

<?php

class GPURIControllerHandler
  extends GPControllerHandler
  implements JsonSerializable {

  public function handle($method, array $args) {
    $index = GPConfig::get()->use_index_php ? '/index.php' : '';
    return $index.'/'.strtolower($this->controller).'/'.$method.
      ($args ? '/'.implode('/', $args) : '');
  }

  public function __toString() {
    return $this->handle('', []);
  }

  public function jsonSerialize() {
    return (string) $this;
  }

}

Make sure URI handler plays nice with json_encode
Make sure URI handler plays nice with json_encode
