JSON validator: Code refactoring