0

I have a class with protected variables

class MyClass {
  protected $moo;
  protected $foo;
}

so when I try to encode an instance to json the result omits the protected vars.

Because of that I first use

$arr =  (array) $instance; 

but than the keys are strange *moo, *foo and I have to

join(explode('\u0000*\u0000',json_encode($arr, JSON_FORCE_OBJECT)));

Any suggestion how to avoid these strange symbols in the first place?

Bat Man
  • 369
  • 1
  • 4
  • 14

0 Answers0