while ($res = mysql_fetch_array($query)){
echo json_encode([
'family'=>$res['family'],
'name'=>$res['name']
]);
}
var obj = JSON.stringify(data)
data = JSON.parse(obj);
{"family":"Петров","value":"Иван"}
{"family":"Иванов","value":"Петр"}
{"family":"Сидоров","value":"Вадим"}