Implement JSON to Zig type unmarshaling/decoding
Summary
Implement the ability to unmarshal/decode JSON into native Zig types, complementing the existing encode() function.
Background
Currently the library supports:
- Parsing JSON into
json.Valuetree - Encoding Zig types to JSON strings
Missing: Direct unmarshaling from JSON bytes/Value to typed Zig structs, arrays, etc.
Proposed API
// Unmarshal JSON bytes directly to a Zig type
pub fn unmarshal(comptime T: type, allocator: Allocator, input: []const u8) !T
// Unmarshal from a json.Value tree
pub fn fromValue(comptime T: type, allocator: Allocator, value: Value) !T
// With options
pub fn unmarshalWithOptions(comptime T: type, allocator: Allocator, input: []const u8, options: DecodeOptions) !TFeatures Required
- Primitive type decoding (bool, integers, floats, strings)
- Optional type handling (null → null)
- Struct field mapping with comptime reflection
- Array/slice decoding
- Enum decoding (from string names)
- Tagged union decoding
- Pointer handling
- Default values for missing fields
- Error reporting with field path
Reference
Go encoding/json v2: Unmarshal, UnmarshalRead, UnmarshalDecode
Priority
Critical - Core functionality gap