conditionally parse .json response