hi guys i got a problem .
while i was implementing some code i reached the point that i need to use toJson method in each object 

so inside the class i have added this code 

```
public function toJson(){
   return json_encode($this);  // $this which refers to the current object 

}

```

it has returned just `{}` so i knew that it does not recognize the properties of this class 
so instead i have tried to convert it like that 

```
public function toJson(){
   $array=(array)$this;
   return json_encode($array);

}

```

i got weird result 

```
string '{"\u0000Response\u0000status":0,"\u0000Response\u0000data":null,"\u0000Response\u0000error":" type non valide "}' (length=112)

```

i could eventually write customized json object

like this 

```
 public function toJson(){
       $myjson="{field1:data1,field2:data2}";
       return $myjson;

    }

```

but i do not want to return back to it each time that i add new property 

i appreciate if you have any idea about why converting this does not work