api/util/json: add JSONAPIErr to reduce code repetition, apply in api/v0