var results = [];
for (var property in object) {
var value = object[property];
if (value)
results.push(property.toString() + ': ' + value);
}
return '{' + results.join(', ') + '}';
}
var obj = { "id":"outsider", "sex":"male" };
obj = JSONtoString(obj);
alert(obj); // {id: outsider, sex: male}
alert(typeof obj); // string
만일 prototype.js 를 쓴다면
alert(Object.toJSON(obj));
// {id: outsider, sex: male}