x.json2: update tests to integrate decoder2 in json2 (#24551)

This commit is contained in:
Hitalo Souza 2025-05-29 11:01:50 +01:00 committed by GitHub
parent 7dc3889f19
commit cd244757db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 18 additions and 32 deletions

View file

@ -546,6 +546,13 @@ pub fn decode[T](val string) !T {
@[manualfree]
fn (mut decoder Decoder) decode_value[T](mut val T) ! {
$if T is $option {
value_info := decoder.current_node.value
if value_info.value_kind == .null {
decoder.current_node = decoder.current_node.next
// val = none // Is this line needed?
return
}
mut unwrapped_val := create_value_from_optional(val.$(field.name))
decoder.decode_value(mut unwrapped_val)!
val.$(field.name) = unwrapped_val