function jsonToString(object) {
var results = [];
for ( var property in object) {
var value = object[property];
if (value)
results.push(property.toString() + ': ' + value);
}

return '{' + results.join(', ') + '}';
}


결과
data = {key: [object Object], model: [object Object], no: 1}

-- 첫번째 항목만 가져온다. 

다시 만들자.



function jsonToString(obj) {
var t = typeof (obj);
    if (t != "object" || obj === null) {
        // simple data type
        if (t == "string") obj = '"'+obj+'"';
        return String(obj);
    } else {
     // recurse array or object
        var n, v, json = [], arr = (obj && obj.constructor == Array);
        for (n in obj) {
            v = obj[n]; t = typeof(v);
            if (t == "string") v = '"'+v+'"';
            else if (t == "object" && v !== null) v = jsonToString(v);
            json.push((arr ? "" : '"' + n + '":') + String(v));
        }
        return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
    }
}
 

모든 항목을 다 풀어서 보여준다.~~ 

이거 쓰면 된다.ㅇㅋ 
Posted by [czar]
,