I have this class:
namespace backoffice\controller;
class MyObject{
private $id;
private $name;
}
I try to convert it to array and then json array:
$obj = new MyObject();
$obj->setId(1);
$obj->setName('Test');
json_encode((array)$obj);
I get this result:
{"backoffice\controller\MyObject\id":"1","backoffice\controller\MyObject\name":"Test"}
!!!!
EDIT:
Why I can't get this result:
{"id":"1","name":"Test"}