Форуми / Cotonti / Support / Question about Json requests

Sergey
#37315 27.03.2013 08:59

Function json_encode does not work correctly. It is with a large array of data gives an error when processing objects and arrays. This function corrects the errors. In the form, I keep the contents of pages, it increases the rate of conversion of pages in a friendly layout:

function object_in_array   	// 	преобразование структуры в массивы. исправление косяка json_decode
	(                       // 	внимание! функция рекурсивная.
 	$объект			//	@param  - сложная структура состоящая из объектов и массивов
  	)
{
if	(!is_object($объект) and !is_array($объект))	return $объект;
if	(is_object($объект))	$объект = get_object_vars($объект);
return array_map('object_in_array',$объект);
}

 

www.cotonti.mobi