dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

Code doubt: Why convert an empty object into an empty array? #1569

Closed xiaohuilam closed 5 years ago

xiaohuilam commented 6 years ago

https://github.com/dingo/api/blob/14225351b2a9b652f6814851539370645c0c1fac/src/Routing/Router.php#L540

Test:

use Illuminate\Http\JsonResponse;

new JsonResponse([
    'key' => 1,
    'object' => new \stdClass(),
]);

after that JsonResponse instanced data pass that line, it becomes

{
    "key": 1,
    "object": []
}

but below format is expected

{
    "key": 1,
    "object": {}
}

Original bug-caused Pull Request https://github.com/dingo/api/pull/1357 temporary patch try usingSymfony\Component\HttpFoundation\JsonResponse instead of Illuminate/Http/JsonResponse

specialtactics commented 5 years ago

Hi

I am not sure what you are trying to say or how this relates to dingo. When using Dingo, I would recommend you use only it's own response helper, and not Laravel's responses.

But in either case, this issue you describe is not related to dingo, and it's not something dingo developers can solve because it requires changes to Laravel.