public static function data_encode($contents, $type = 'json') { switch ($type) { case 'json': return json_encode($contents, JSON_FORCE_OBJECT); case 'xml': return RestUtils::xml_encode('nebula', $contents); } }