deal with json only in one place