v/vlib/json
yuyi de136f6baf
checker: improve pub struct check (fix #14446) (#14777)
2022-06-19 17:42:22 +03:00
..
README.md fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
json_decode_test.v fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
json_decode_with_encode_arg_test.v fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
json_decode_with_generic_test.v checker: fix json decoder with generic struct (#14700) 2022-06-06 19:25:02 +03:00
json_decode_with_optional_arg_test.v fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
json_decode_with_sumtype_test.v fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
json_primitives.v checker: improve pub struct check (fix #14446) (#14777) 2022-06-19 17:42:22 +03:00
json_test.v json: fix json decode with missing map type field (#14678) 2022-06-04 20:27:11 +03:00

README.md

Description:

json provides encoding/decoding of V data structures to/from JSON.

Examples:

import json

enum JobTitle {
	manager
	executive
	worker
}

struct Employee {
	name   string
	age    int
	salary f32
	title  JobTitle
}

fn main() {
	x := Employee{'Peter', 28, 95000.5, .worker}
	println(x)
	//
	s := json.encode(x)
	println('Employee x: $s')
	assert s == '{"name":"Peter","age":28,"salary":95000.5,"title":2}'
	//
	y := json.decode(Employee, s)?
	//
	println(y)
	assert y == x
}