public function toJson() {
    	$result = array();
    	$result['name'] = $this->getName();
    	$result['hasDefault'] = $this->isDefaultValueAvailable();
    	try {
    		if ($result['hasDefault']) {
    			// In some cases, the call to getDefaultValue can log NOTICES
    			// in particular if an undefined constant is used as default value.
    			ob_start();
    			if ($this->isDefaultValueConstant() && !defined($this->getDefaultValueConstantName())) {
    			    throw new \Exception('Constant "'.$this->getDefaultValueConstantName().'" does not exist.');
                }
    			$result['default'] = $this->getDefaultValue();
    			$possibleError = ob_get_clean();
    			if ($possibleError) {
    				throw new \Exception($possibleError);
    			}
    		}
    		$result['isArray'] = $this->isArray();
    		
    		// Let's export only the type if we are in a constructor... in order to save time.
    		if ($this->getDeclaringFunction()->isConstructor()) {
    			// TODO: is there a need to instanciate a  MoufPropertyDescriptor?
    			$moufPropertyDescriptor = new MoufPropertyDescriptor($this);
    
    			$result['comment'] = $moufPropertyDescriptor->getDocCommentWithoutAnnotations();
    
    	    	$types = $moufPropertyDescriptor->getTypes();
	    		$result['types'] = $types->toJson();
	    	 
	    		if ($types->getWarningMessage()) {
	    			$result['classinerror'] = $types->getWarningMessage();
	    		}
    			
    			/*if ($moufPropertyDescriptor->isAssociativeArray()) {
    				$result['keytype'] = $moufPropertyDescriptor->getKeyType();
    			}
    			if ($moufPropertyDescriptor->isArray()) {
    				$result['subtype'] = $moufPropertyDescriptor->getSubType();
    			}*/
    		}
    	} catch (\Exception $e) {
    		$result['classinerror'] = $e->getMessage();
    	}
    
    	return $result;
    }