mtv\models\Model::set_from_json PHP Method

set_from_json() public method

Update this model from json data sent over the wire
public set_from_json ( &$data )
    public function set_from_json(&$data)
    {
        // decide which fields to use from the wire
        $new_data = (array) json_decode(stripslashes($data), true);
        if (empty($this->editable_json_fields)) {
            $this->set($new_data);
        } else {
            foreach ($new_data as $k => $v) {
                if (in_array($k, $this->editable_json_fields)) {
                    $this->{$k} = $v;
                }
            }
        }
    }