serialize objects with millions of keys without blowing the stack

Fixes #7