Bug 656632 - Remove the duplicate code in JSObjectEncoder.