Level 24
This will base it off the headers so if that is ok (i.e. content type is application/json)...
if(request()->isJson()){
//it is json, continue
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi
How can I check globally if a given incoming request is in JSON format?
And if it isn't, convert the request to JSON and pass it on.
json-> json-> next ...
text-> json-> next ...
This will base it off the headers so if that is ok (i.e. content type is application/json)...
if(request()->isJson()){
//it is json, continue
}
Please or to participate in this conversation.