turn toJSON into a tight loop