I like to respond a Json like this

'{"name":"John", "age":30, "car":null}'

How is this possible with thos class:


It looks as I only can have link, data and jsonapi at the first Level of the JsonResponse.

  • 1
    Does JSON:API even allow that? Maybe you need generic JSON output instead?
    – Sharky
    Commented Dec 20, 2022 at 8:12
  • Thank you. You are right, this not allowed: jsonapi.org/format/#document-top-level . How is the recommanded way to realise an output like this in Joomla? Is there an example?
    – agi
    Commented Dec 20, 2022 at 8:34
  • Do you need this in the API application? Or in site/administrator?
    – Sharky
    Commented Dec 21, 2022 at 20:22
  • I have not been able to solve this in the api yet either. I have used the view to a component like here: github.com/joomla/joomla-cms/tree/4.2-dev/administrator/… .
    – agi
    Commented Dec 22, 2022 at 12:53

1 Answer 1


Joomla\CMS\MVC\View\JsonApiView view class is meant for generating JSON:API compliant output. For generic/custom JSON you can use the Joomla\CMS\MVC\View\JsonView class instead.

  • Is more tricky than that I think. I was trying get it done, and not work so far. Even when all is working (the controller connect with the view....etc) the result is a empty array []. Also, the headers output still application/vnd.api+json not matter what you try to change to the Document in the JsonView.... Commented Dec 21, 2022 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.