I expect the following code to throw a json parsing error:
const std = @import("std");
test {
const foo = .{
.a = std.math.inf(f32),
};
const str = try std.json.stringifyAlloc(std.testing.allocator, foo, .{});
defer std.testing.allocator.free(str);
std.log.warn("{s}", .{str});
}
The output:
{"a":inf}
Which is not valid json - inf is not a keyword valid in json. Is this just a bug in the std library, or is there another way to represent infinite values?