Java Requires Chilkat v11.0.0+
Chilkat2 Java
Example: Http.GetLastJsonData method
Demonstrates theGetLastJsonData method.
Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.JsonObject;
public class ChilkatExample {
public static void main(String[] args) {
Http http = new Http();
HttpResponse resp = new HttpResponse();
// Only allow TLS 1.2 or better.
http.setSslProtocol("TLS 1.2 or higher");
try {
http.httpNoBody("GET", "https://google.com/", resp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
JsonObject json = new JsonObject();
json.setEmitCompact(false);
http.getLastJsonData(json);
System.out.println(json.emit());
// Output as of Chilkat v11.1.0
// Additional information may be added as requested or needed in future versions of Chilkat.
// {
// "tls": {
// "params": {
// "sniHostname": "www.google.com",
// "allowConnectionOnlyIfServerChooses": "TLS 1.2 or higher"
// },
// "negotiatedTlsVersion": "TLS 1.3"
// }
// }
}
}