Fetching JSON data from website

I have this:

/*
 DNS and DHCP-based Web client 

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13 
*/

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
byte mac[] = {  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.jsontest.com";

// Initialize the Ethernet client library
EthernetClient client;

void setup() {
 // start the serial library:
 Serial.begin(9600);
 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
   Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
   while(true);
 }
 // give the Ethernet shield a second to initialize:
 delay(1000);
 Serial.println("connecting...");

 // if you get a connection, report back via serial:
 
 if (client.connect(serverName, 80)) {
   Serial.println("connected");
   // Make a HTTP request:
   client.println("GET ip.jsontest.com HTTP/1.1");
   client.println();
 } 
 else {
   // if you didn't get a connection to the server:
   Serial.println("connection failed");
 }
}

void loop()
{
 // if there are incoming bytes available 
 // from the server, read them and print them:
 if (client.available()) {
   char c = client.read();
   Serial.print(c);
 }

 // if the server's disconnected, stop the client:
 if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();

   // do nothing forevermore:
   while(true);
 }
}

Which is only giving this:

connecting...
connected
HTTP/1.1 400 Bad Request
Server: GitHub.com
Content-Type: text/html; charset=utf-8
Content-Length: 166
Accept-Ranges: bytes
Date: Sat, 27 Jun 2015 16:31:41 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Served-By: cache-lhr6320-LHR
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1435422701.463229,VS0,VE82
Vary: Accept-Encoding

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

I know I’m being stupid but all i want to do is serial print this: http://ip.jsontest.com/

Anyone able to give me a knock on the head?

http://ip.jsontest.com/ returns your ip in JSON form.

If this is what you want, shouldn't you be using this as the server name?

As i said, something stupid. I was sure i had tried that, but apparently not. Thank you very much dude

Right, so it works great now on that ip page, which was a test page. The page i need it to read is www.askaran.co.uk, and after changing the server name and GET request URL to either www.askaran.co.uk or http://www.askaran.co.uk or http://askaran.co.uk i get a "Connecting, connected, disconnecting" or an instant 400 bad request. :/

Yes! Wrong bloody HTTP version. Thank you! :D

So it works fine? Noticed on askaran the JSON format was a bit off, but I guess you parse that out in code.

Aye, I just some text in there to test, without keying it properly. Now onto stage two: parsing :D

There's a json parser library out there. No need to reinvent the wheel.

Sometimes re-inventing the wheel lets you learn exactly how that wheel works.

It's just boring char string parsing. It takes too much time for what it's worth. I've written one for url query string parsing.

Ohh definitely. If you know how it works, and it works as efficiently as you could write, then go for the library every time.

But if you can still learn from doing it, I say go for it.