mirror of
https://github.com/vlang/v.git
synced 2025-09-14 23:12:33 +03:00
json: fix ptr field access (#17690)
This commit is contained in:
parent
aee76c5819
commit
2df23a6698
2 changed files with 51 additions and 5 deletions
42
vlib/json/json_encode_with_mut_test.v
Normal file
42
vlib/json/json_encode_with_mut_test.v
Normal file
|
@ -0,0 +1,42 @@
|
|||
module main
|
||||
|
||||
import json
|
||||
|
||||
pub enum PlatformType {
|
||||
unknown
|
||||
osx
|
||||
ubuntu
|
||||
alpine
|
||||
}
|
||||
|
||||
pub enum CPUType {
|
||||
unknown
|
||||
intel
|
||||
arm
|
||||
intel32
|
||||
arm32
|
||||
}
|
||||
|
||||
[heap]
|
||||
pub struct Node {
|
||||
pub:
|
||||
name string = 'mymachine'
|
||||
pub mut:
|
||||
platform PlatformType
|
||||
cputype CPUType
|
||||
done map[string]string
|
||||
environment map[string]string
|
||||
}
|
||||
|
||||
pub fn (mut node Node) save() ! {
|
||||
data := json.encode(node)
|
||||
dump(data)
|
||||
}
|
||||
|
||||
fn test_encode_with_mut_struct() {
|
||||
mut n := Node{
|
||||
platform: .osx
|
||||
cputype: .unknown
|
||||
}
|
||||
n.save() or { panic(err) }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue