function objectToString (obj) {

        var str = '';

        var i=0;

        for (var key in obj) {

            if (obj.hasOwnProperty(key)) {

                if(typeof obj[key] == 'object')

                {

                    if(obj[key] instanceof Array)

                    {

                        str+= key + ' : [ ';

                        for(var j=0;j<obj[key].length;j++)

                        {

                            if(typeof obj[key][j]=='object') {

                                str += '{' + objectToString(obj[key][j]) + (j > 0 ? ',' : '') + '}';

                            }

                            else

                            {

                                str += '\'' + obj[key][j] + '\'' + (j > 0 ? ',' : ''); //non objects would be represented as strings

                            }

                        }

                        str+= ']' + (i > 0 ? ',' : '')

                    }

                    else

                    {

                        str += key + ' : { ' + objectToString(obj[key]) + '} ' + (i > 0 ? ',' : '');

                    }

                }

                else {

                    str +=key + ':\'' + obj[key] + '\'' + (i > 0 ? ',' : '');

                }

                i++;

            }

        }

        return str;

    }

Posted by MR 손
,