How to send JSON response using socket in Java
问题 I have built a basic HTTP server and I am attempting to send a reply to a GET request. I have installed Gson as the JSON parser, but I'm not sure how to encode the response in JSON and send back to the client. Here is my code, any help is much appreciated. (last method for actual response) public class HttpServer extends Thread{ //Private variables private Socket connectedClient = null; private BufferedReader clientRequest = null; private DataOutputStream responseToClient = null; /** * Public