Sample code for 30+ languages & platforms
Zig Requires Chilkat v11.0.0+

Example: Http.GetLastJsonData method

Demonstrates the GetLastJsonData method.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    const http = try chilkat.Http.init();
    defer http.deinit();
    const resp = try chilkat.HttpResponse.init();
    defer resp.deinit();

    // Only allow TLS 1.2 or better.
    http.setSslProtocol("TLS 1.2 or higher");

    http.httpNoBody("GET", "https://google.com/", resp) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    const json = try chilkat.JsonObject.init();
    defer json.deinit();
    json.setEmitCompact(false);

    http.getLastJsonData(json);
    std.debug.print("{s}\n", .{try json.emit(alloc)});

    // 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"
    //   }
    // }
}