Function stringifyAlloc [src]

Alias for std.json.stringify.stringifyAlloc

Calls stringifyArbitraryDepth and stores the result in dynamically allocated memory instead of taking a std.io.Writer. Caller owns returned memory.

Prototype

pub fn stringifyAlloc( allocator: Allocator, value: anytype, options: StringifyOptions, ) error{OutOfMemory}![]u8

Parameters

allocator: Allocatoroptions: StringifyOptions

Possible Errors

OutOfMemory

Source

pub fn stringifyAlloc( allocator: Allocator, value: anytype, options: StringifyOptions, ) error{OutOfMemory}![]u8 { var list = std.ArrayList(u8).init(allocator); errdefer list.deinit(); try stringifyArbitraryDepth(allocator, value, options, list.writer()); return list.toOwnedSlice(); }