move basic json logic into a base handler class