Skip to content

[FrameworkBundle] Deserialize json in AbstractController #38572

@henry2778

Description

@henry2778

Description
Hi! Sorry in advance if that issue is a duplicate (didn't find anything like it). What if we add new method in AbstractController to deserialize from json (opposite to AbstractController::json()) ? AbstractController already has lots of methods, but still this opertation seem to be routine one while developing APIs :)

Example

protected function fromJson(string $body, string $to, array $context = [])
{
    // check if serializer available
    // return deserialized value
}

...

public function createUser(Request $request)
{
    $resource = $this->fromJson($request->getContent(), UserResource::class);
}

If OK, I would like to implement it.

WDYT? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions