Refactor restful JSON interface