I need to convert to a JSON value the result of a DOMRect object returned by Element.getBoundingClientRect()
Here an example:
http://jsfiddle.net/5v
Bounding rect only contains "virtual" properties. If you
console.log(Object.getOwnPropertyNames(r));
// or
console.log(Object.keys(r));
you'll get an empty list. JSON.stringify()
depends on Object.keys(r)
(see comments below) and thus returns an empty object literal.
Your loop-based approach seems to be a feasible solution to this problem.