<?php

class DataSerializer {

	static private $instance=null;
	
	static public function serialize($var){
	 	
		if(function_exists(json_encode)) {
			return json_encode($var);
		}
	 	 	
	 	if(self::$instance==null)self::makeInstance();
		return self::$instance->serialize($var);
	}
	 
	static public function deserialize($var){
	 
	 	if(function_exists(json_decode)){
		   return json_decode($var);
		}
	 	
		if(self::$instance==null)self::makeInstance();
		return self::$instance->deserialize($var);
	}
	
	
	static private function makeInstance(){
		self::$instance = new Services_JSON();
	}
	
}