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;
}
}
}
}