public function toJSON()
    {   
        $allvals = Array();
        $reflection = new \ReflectionObject($this);
        $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
        foreach($properties as $prop){
            $propkey = $prop->getName();
            $allvals[$propkey] = $this->$propkey;
        }
        $json = json_encode($allvals, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        return $json;
    }
public function toJSON()
    {   
        $allvals = Array();
        $reflection = new \ReflectionObject($this);
        $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
        foreach($properties as $prop){
            $propkey = $prop->getName();
            $allvals[$propkey] = $this->$propkey;
        }
        $json = json_encode($allvals, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        return $json;
    }
public function toJSON ( ) { $ allvals = Array ( ) ; $ reflection = new \ ReflectionObject ( $ this ) ; $ properties = $ reflection -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) ; foreach ( $ properties as $ prop ) { $ propkey = $ prop -> getName ( ) ; $ allvals [ $ propkey ] = $ this -> $ propkey ; } $ json = json_encode ( $ allvals , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ; return $ json ; }
Outputs the object as a JSON
Outputs the object as a JSON