JsonHelper::removeCommentsAndDecode() 

\nn\t3::JsonHelper()->removeCommentsAndDecode($str, $useArray = true); 

Removes comments from the code and parses the string.

\Nng\Nnhelpers\Helpers\JsonHelper::removeCommentsAndDecode( "// Comment\n{title:'Test', cat:[2,3,4]}" )
Copied!

| @return array|string

Source Code 

public static function removeCommentsAndDecode($str, $useArray=true) {
	$str = preg_replace('/\'([^\']*)(\/\/)([^\']*)\'/', '\'\1\\/\\/\3\'', $str);
	$str = preg_replace('/"([^"]*)(\/\/)([^"]*)"/', '"\1\\/\\/\3"', $str);
	$str = (new \Ahc\Json\Comment)->strip($str);
	$str = str_replace("\\/\\/", '//', $str);
	return self::decode( $str, $useArray );
}
Copied!