Tag: request

Reading incoming JSON bodies in Symfony

Accepting JSON encoded data from requests is crucial when developing APIs. By default, Symfony will not unserialize the object as an array, and you need a little workaround to make it available as you would with any form submitted request.

We can make use of an EventSubscriber to have the JSON content always decoded and put in $request->request.