fix json dump bug, and introduce helper