/* 将对象转为字符串 */
function objectToString( obj )
{
var str = "" ;
c = obj.constructor;
for ( var i in obj)
{
var e = obj[i];
switch ( typeof (e)){
case " number " :
if ( c == Array )
str += " ' " + e + " ' , " ;
else if ( c == Object )
str += " ' " + i + " ' : ' " + e + " ' , " ;
break ;
case " string " :
if ( c == Array )
str += " ' " + e + " ' , " ;
else if ( c == Object )
str += " ' " + i + " ' : ' " + e + " ' , " ;
break ;
case " boolean " :
if ( c == Array )
str += " ' " + e + " ' , " ;
else if ( c == Object )
str += " ' " + i + " ' : ' " + e + " ' , " ;
break ;
case " function " :
break ;
case " undefined " :
break ;
case " object " :
if ( e.constructor == Array )
str += " [ " + i + " ]= new Array( " + objectToString( e ) + " );\n " ;
else if ( e.constructor == Object )
str += " ' " + i + " ' : { " + objectToString( e ) + " } ,\n " ;
break ;
} // switch
} // for
return str.substr( 0 ,str.length - 1 );
} // func
// "number," "string," "boolean," "object," "function," 和 "undefined."
function countObjLength( obj )
{
var i = 0 ;
for ( var k in obj){
i ++ ;
}
return i;
}