# Only JSON outputs

**URL:** https://discourse.slimframework.com/t/only-json-outputs/1361
**Category:** Questions
**Created:** [April 2, 2017, 12:03pm UTC](https://discourse.slimframework.com/t/only-json-outputs/1361 "2017-04-02T12:03:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![yoX64](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@yoX64](https://discourse.slimframework.com/u/yoX64)
#### Post date: [April 2, 2017, 12:03pm UTC](https://discourse.slimframework.com/t/only-json-outputs/1361/1 "2017-04-02T12:03:55Z")

</div>

Hello,

I am building an API with Slim framework and I would be interested in only having JSON outputs, not only for routes but for every error or message that the framework would throw. Is this possible?

Thank you.

---

<div class="post-metadata">

### Author: ![akrabat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/akrabat/32/9_2.png) [@akrabat](https://discourse.slimframework.com/u/akrabat)
#### Post date: [April 3, 2017, 12:38pm UTC](https://discourse.slimframework.com/t/only-json-outputs/1361/2 "2017-04-03T12:38:38Z")

</div>

This happens by default if the client sets their Accept header to application/json.

Otherwise, you can override the error handling to do force it yourself.

---

<div class="post-metadata">

### Author: ![yoX64](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@yoX64](https://discourse.slimframework.com/u/yoX64)
#### Post date: [April 3, 2017, 1:02pm UTC](https://discourse.slimframework.com/t/only-json-outputs/1361/3 "2017-04-03T13:02:49Z")

</div>

That’s great.

Thanks.

---

<div class="post-metadata">

### Author: ![viralpatel](https://avatars.discourse-cdn.com/v4/letter/v/51bf81/32.png) [@viralpatel](https://discourse.slimframework.com/u/viralpatel)
#### Post date: [April 4, 2017, 3:31pm UTC](https://discourse.slimframework.com/t/only-json-outputs/1361/4 "2017-04-04T15:31:24Z")

</div>

What if I wish to force JSON output ?

---

<div class="post-metadata">

### Author: ![viralpatel](https://avatars.discourse-cdn.com/v4/letter/v/51bf81/32.png) [@viralpatel](https://discourse.slimframework.com/u/viralpatel)
#### Post date: [April 5, 2017, 10:51am UTC](https://discourse.slimframework.com/t/only-json-outputs/1361/5 "2017-04-05T10:51:32Z")

</div>

I think I found the solution by using withJson() !

Thanks.
