Arduino Mega web server always returning JSON data even if JSON is not passed in URL
So figured out the problem, the issue was  I was closing the connection instead when it was json fetched, I had to keep alive the connection.

so replaced client.println("Connnection: close"); with  client.println("Connection: keep-alive");

which fixed the problem.