Fix max call stack exec when calling toJSON on a newly saved doc.