How do I load json abi #148
Answered
by
Raiden1411
eniolasonowo
asked this question in
Q&A
-
|
How do I load a json abi, I don't want to use human readable abi . |
Beta Was this translation helpful? Give feedback.
Answered by
Raiden1411
Mar 12, 2025
Replies: 1 comment 1 reply
-
|
You can read from a file and json parse it like so const abi = @import("zabi-abi"); // or const abi = @import("zabi").abi;
const file = try std.fs.cwd().openFile("abi.json", .{});
defer file.close();
const content = try file.readToEndAlloc(std.heap.page_allocator, std.math.maxInt(u32));
defer std.heap.page_allocator.free(content);
const parsed = try std.json.parseFromSlice(abi.Abi, std.heap.page_allocator, content, .{});
defer parsed.deinit(); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
eniolasonowo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can read from a file and json parse it like so