Function fmt [src]
Alias for std.json.fmt.fmt
Returns a formatter that formats the given value using stringify.
Prototype
pub fn fmt(value: anytype, options: StringifyOptions) Formatter(@TypeOf(value))
Parameters
options: StringifyOptions
Example
test fmt {
const expectFmt = std.testing.expectFmt;
try expectFmt("123", "{}", .{fmt(@as(u32, 123), .{})});
try expectFmt(
\\{"num":927,"msg":"hello","sub":{"mybool":true}}
, "{}", .{fmt(struct {
num: u32,
msg: []const u8,
sub: struct {
mybool: bool,
},
}{
.num = 927,
.msg = "hello",
.sub = .{ .mybool = true },
}, .{})});
}
Source
pub fn fmt(value: anytype, options: StringifyOptions) Formatter(@TypeOf(value)) {
return Formatter(@TypeOf(value)){ .value = value, .options = options };
}