Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty object as an array instead of object #1

Open
alibo opened this issue Jun 11, 2015 · 0 comments
Open

Empty object as an array instead of object #1

alibo opened this issue Jun 11, 2015 · 0 comments

Comments

@alibo
Copy link
Member

alibo commented Jun 11, 2015

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": [] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant