Format

1
2
3
4
demo_remove:
   path:         clients/{client}
   controller:   LMS\Demo\Controller\DemoApiController::test
   format:       json

Tip

Required: No

Variants: json | pdf | txt | print | rss | atom | any other…

Tip

By default ( when methods is not specified ) we use default system value which is html

Example

1
2
3
4
 my_example:
   path:         api/demo/test
   controller:   LMS\Demo\Controller\DemoApiController::test
   format:       json

Tip

  1. EXT:demo/View/DemoApi/TestJson.php: expected to be in place.
namespace LMS\Demo\View\DemoApi;

class TestJson extends \TYPO3\CMS\Extbase\Mvc\View\AbstractView
{
    public function render()
    {
        return json_encode(['ok' => true]);
    }
}

Tip

2. Or alternatively, EXT:demo/Resources/Private/Templates/DemoApi/Test.json: expected to be in place. In this case $defaultViewObjectName should not be overwritten.

{
  "status": "ok"
}