// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

import com.google.gson.Gson;

public class ReadJSON {
    public static void main(String[] args) throws Exception {
        HttpClient client = new HttpClient();
        GetMethod get = new GetMethod("http://localhost:81/somejson.php");
        client.executeMethod(get);
        String json = get.getResponseBodyAsString();
        System.out.println(json);
        Gson gson = new Gson();
        Data o = gson.fromJson(json, Data.class);
        System.out.println(o.getIv() + " " + o.getSv());
    }
}

class Data {
    private int iv;
    private String sv;
    public int getIv() {
        return iv;
    }
    public void setIv(int iv) {
        this.iv = iv;
    }
    public String getSv() {
        return sv;
    }
    public void setSv(String sv) {
        this.sv = sv;
    }
}
