server: refactor common json tasks