Fix an issue of putting object into JSON object too early.