public static function toObject(&$array, $class='\\stdClass')
  {
    $obj = null;
    if ( is_array($array) ){
      $obj = new $class;
      foreach($array as $k => $v){
        if ( is_array($v) ){
          $obj->$k = self::toObject($v, '\\stdClass');
        }
        else {
          $obj->$k = $v;
        }
      }
    }
    return $obj;
  }