UNO webserver needs to send out JSON

I will post the important part of my code here, no reason to paste it all. What I have as an arduino UNO hooked up to an anemometer and 2 temperature sensors. This is being placed on top of a mountain in a ham radio repeater shack where we also have Mesh Networking gear. The Mesh network is a wireless network free from the internet that lets us communicate with computers just like it was over the internet. so What the weather station does is post a simple HTML webpage with Wind speed, Wind direction, outside Temperature, and Temperature inside the shack. this simple page updates every 5 seconds and is viewable on the mesh network where we dont need anything fancy, just current conditions. what we want to do is add JSON to the arduino code so that another computer will take the Wind speed, Wind direction, outside Temperature, and Temperature inside the shack and let us perform some calculations on the info and allow us to post information to a different webpage, like High and low Temp and High and low wind speeds for the last 10 days, week, month Year, and all time high and lows. The question I have is how do I add the values of my sensors to be output in a JSON format to be processed by a second computer[code]
if (c == ‘\n’ && currentLineIsBlank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”); // the connection will be closed after completion of the response
client.println(“Refresh: 5”); // refresh the page automatically every 5 sec
client.println();
client.println("");
client.println("");
client.print("Wind Speed: “);
client.println(WindSpeed);
client.println(”
");
client.print("Knots: “);
client.println(getKnots(WindSpeed));
client.println(”
");
client.print("Strength: “);
client.print(strength);
(getWindStrength(WindSpeed));
client.println(”
“);
client.print(“Direction: “);
client.print(CalDirection);
(getHeading(CalDirection));
client.print(”&deg”);
client.println(”
");
client.print("Compas Direction: “);
client.print(compDirection);
client.println(”
“);
client.print(“temp 1: “);
client.print(temperature1);
client.print(”&deg”);
client.println(”
“);
client.print(“temp 2: “);
client.print(temperature2);
client.print(”&deg”);
client.println(”
");

client.println("");
break;
}
if (c == ‘\n’) {
// you’re starting a new line
currentLineIsBlank = true;
} else if (c != ‘\r’) {
// you’ve gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println(“client disconnected”);
}

[/code]

I just need to send Knots, Direction, Temperature1, and Temperature2 in the JSON format. those are the Variables for my sensor data.

You want to do a GET to the same URL and receive JSON? No.

You could just format the output in JSON instead of HTML and call it a day, or you'll need to sort it and direct the output based on what is requested... a query string for example...

Yes, another computer on the network will send a her request to the same IP address as the HTML version is on. So do I need to place my JSON directly after the tag?

You would return JSON instead of the html. So the question is: how is your arduino supposed to know which one to generate?

The "right" way is to look at the HTTP "Accept" header and see if the client wants JSON. But that's complicated (because the accept header has a potentially complicated format).

The easier way is to look at the GET request. If the client is asking for "/data.json", produce the JSON, other wise produse the html. This means that whatever it is that is fetching the data needs to know that it has to request http://arduino-ip-address/data.json.

In your response, change the content-type to "application/json", and do a whole separate block of print statements to actually produce the json you want.