Extract json post stuff into a reusable util function