Refactored JSON handler into two classes