Skip to content

Empty object as an array instead of object #1

@alibo

Description

@alibo

for empty objects, it returns array instead of empty object ( { } ) :

Model:

Class Model {
    /**
     * @var int
     */
    public $status;

    /**
     * @SerializedName("data")
     * @PsonType("App\Api\Models\Responses\ResponseModel")
     * @var ResponseModel
     */
    public $data;
}

EmptyModel:

Class EmptyModel implements ResponseModel {

}

Serializing Model with Pson:

$model = new Model();
$model->status = 200;
$model->data = new EmptyModel();

echo $pson->toJson($data);
{ "status": 200, "data": [] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions