mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
json2.decoder2: prepare decoder in json2 to be replaced by json2.decode2 (#23078)
This commit is contained in:
parent
210239fb01
commit
de3b184b01
11 changed files with 63 additions and 22 deletions
|
@ -777,10 +777,25 @@ fn (mut decoder Decoder) decode_value[T](mut val T) ! {
|
|||
}
|
||||
|
||||
if current_field_info.value.is_raw {
|
||||
$if field.typ is $enum {
|
||||
$if field.unaliased_typ is $enum {
|
||||
// workaround to avoid the error: enums can only be assigned `int` values
|
||||
return error('`raw` attribute cannot be used with enum fields')
|
||||
} $else $if field.typ is string || field.typ is ?string {
|
||||
} $else $if field.typ is ?string {
|
||||
position := decoder.current_node.value.position
|
||||
end := position + decoder.current_node.value.length
|
||||
|
||||
val.$(field.name) = decoder.json[position..end]
|
||||
decoder.current_node = decoder.current_node.next
|
||||
|
||||
for {
|
||||
if decoder.current_node == unsafe { nil }
|
||||
|| decoder.current_node.value.position + decoder.current_node.value.length >= end {
|
||||
break
|
||||
}
|
||||
|
||||
decoder.current_node = decoder.current_node.next
|
||||
}
|
||||
} $else $if field.typ is string {
|
||||
position := decoder.current_node.value.position
|
||||
end := position + decoder.current_node.value.length
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue