Split out web request JSON request serialization into functions that can be overridden. Added handling for invalid web response.