mercredi 1 juillet 2015

The php json_encode($object) output object namespace

I try to use json_encode() an object but the result has namespace prefix before every direct member variable. The class like this:

namespace common\model;

class MyObj {

    private $f1 = 0;
    private $f2 = 2;
    .....
}

The output like this:

{"\u0000common\\model\\MyObj\u0000f1":0,"\u0000common\\model\\MyObj\u0000f2":2,

how to make the json output without the namespace prefix? my PHP version is 5.6.10.

Aucun commentaire:

Enregistrer un commentaire