Replacing _json with serialize method & Flake8ify  #3895

Review ID - 2833002