Skip to content

Commit

Permalink
fix x.json2 &nil checking
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 23, 2025
1 parent a099589 commit 1eb2948
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vlib/x/json2/encoder.v
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,14 @@ fn (e &Encoder) encode_struct[U](val U, level int, mut buf []u8) ! {
mut ignore_field := false

value := val.$(field.name)

is_nil := val.$(field.name).str() == '&nil'

mut is_nil := false
$if value is $option {
if field.indirections > 0 {
is_nil = value == none
}
} $else $if field.indirections > 0 {
is_nil = value == unsafe { nil }
}
mut json_name := ''

for attr in field.attrs {
Expand Down

0 comments on commit 1eb2948

Please sign in to comment.