title: How to change Joomla component's view default format?
body: <p>I have a custom Joomla 3.4.1 component which has a view that displays data either in JSON format (from views/myview/view.json.php file) or HTML (from views/myview/view.html.php file) format. Is there a way how to change the default view's format from HTML to JSON so that</p>
  
  <pre><code>http://example.com/component/mycomponent/myview
  </code></pre>
  
  <p>returns JSON data instead of HTML while:</p>
  
  <pre><code>http://example.com/component/mycomponent/myview?format=html
  </code></pre>
  
  <p>still returns the HTML template of the view?</p>
  
  <p>EDIT:</p>
  
  <p>As far as I get is this router:</p>
  
  <pre><code>function TouristGuideParseRoute($segments) {
    $count = count($segments);
    $parameters = array();
    if ($count &gt; 0) {
      $parameters['view'] = $segments[0];
    }
    if ($count &gt; 1) {
      $parameters['task'] = $segments[1];
    }
    if ($count &gt; 2) {
      $parameters['id'] = $segments[2];
    }
    if ($count &gt; 3) {
      $parameters['format'] = $segments[3];
    }
  
    if (($parameters['view'] == 'api') &amp;&amp; empty($parameters['format'])) {
      $application = JFactory::getApplication();
      $input = $application-&gt;input;
      $parameters['format'] = $input-&gt;getString('format', 'json');
    }
    return $parameters;
  }
  </code></pre>
  
  <p>which displays JSON format even if URL contains <code>?format=html</code> because in this router the <code>$application-&gt;input</code> is empty (probably populated later on in Joomla request processing chain) and thus <code>$input-&gt;getString('format','json')</code> returns <code>json</code> all the time.</p>