I’m trying to figure out how to gather partial strings with allocNextIntoArrayList. The problem is that I keep getting nulls.
The string that I’m parsing is Habitat \u0026 Description
I think that is a .partial, .partial_escaped, & .string
Paring down the code to the essential bits:
var scanner = std.json.Scanner.initCompleteInput(self.allocator, annos);
defer scanner.deinit();
while (true) {
switch (try scanner.peekNextTokenType()) {
.end_of_document => {
std.debug.print("EOD\n", .{});
break;
},
<<<snip>>>
.string => switch (try scanner.next()) {
.string => |value| {
std.debug.print("string {s}\n", .{value});
},
.partial_string,
.partial_string_escaped_1,
.partial_string_escaped_2,
.partial_string_escaped_3,
.partial_string_escaped_4,
=> {
var buff = std.ArrayListAligned(u8, null).init(self.allocator);
defer buff.deinit();
const str = (try scanner.allocNextIntoArrayList(&buff, .alloc_if_needed)) orelse "";
std.debug.print("PARTIAL STRING '{s}'\n", .{str});
},
else => unreachable,
},
<<<snip>>>
}
}