mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
mcp: improve RawJson stringification and schema formatting
- Update `RawJson.jsonStringify` to parse and re-write JSON content, ensuring valid output. - Reformat tool input schemas in `tools.zig` using multi-line string literals for better readability.
This commit is contained in:
@@ -101,9 +101,13 @@ pub const RawJson = struct {
|
||||
json: []const u8,
|
||||
|
||||
pub fn jsonStringify(self: @This(), jw: anytype) !void {
|
||||
try jw.beginWriteRaw();
|
||||
try jw.writer.writeAll(self.json);
|
||||
jw.endWriteRaw();
|
||||
var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
const parsed = std.json.parseFromSlice(std.json.Value, arena.allocator(), self.json, .{}) catch return error.WriteFailed;
|
||||
defer parsed.deinit();
|
||||
|
||||
try jw.write(parsed.value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user