v
v copied to clipboard
(json2) Struct with optional field results in leading comma
V doctor:
OS: windows, Microsoft Windows 11 Home v22621 64-bit
Processor: 16 cpus, 64bit, little endian,
CC version: Error: exec failed (CreateProcess) with code 2: The system cannot find the file specified.
cmd: cc --version
getwd: C:\Users\Daniel\Projects\vjwt
vmodules: C:\Users\Daniel\.vmodules
vroot: C:\Users\Daniel\Projects\v
vexe: C:\Users\Daniel\Projects\v\v.exe
vexe mtime: 2023-03-08 09:07:59
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.3 2597efa.476b1bf
Git version: git version 2.39.2.windows.1
Git vroot status: weekly.2023.10-13-g476b1bf4
.git/config present: true
thirdparty/tcc status: thirdparty-windows-amd64 e90c2620
What did you do?
v -g -o vdbg cmd/v && vdbg main.v
import x.json2
struct JoseHeader {
pub mut:
cty ?string
alg string
typ string = 'JWT'
}
fn main() {
res := json2.encode(JoseHeader{alg: 'HS256'})
dump(res)
}
What did you expect to see?
No comma in front of the first attribute
What did you see instead?
[main.v:13] res: {,"alg":"HS256""typ":"JWT"}
@enghitalo