Refactoring json-api