json parsing refactoring