1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/json
2023-07-09 08:23:24 +03:00
..
cjson
json_alias_test.v
json_decode_test.v json: skip via the "-" attribute 2023-05-02 16:41:32 +02:00
json_decode_with_encode_arg_test.v
json_decode_with_generic_array_test.v checker: fix json decode with generic array of struct (fix #18300) (#18308) 2023-05-30 14:25:33 +02:00
json_decode_with_generic_test.v
json_decode_with_option_arg_test.v
json_decode_with_sumtype_test.v
json_encode_enum_test.v
json_encode_map_test.v
json_encode_primite_test.v
json_encode_struct_with_option_field_test.v
json_encode_sumtype_test.v json: fix option sumtype with int types (#18013) 2023-04-22 10:58:01 +03:00
json_encode_with_mut_test.v
json_encode_with_ptr_test.v
json_generic_array_test.v
json_omitempty_test.v
json_omitempty_types_test.v cgen: include float kind in struct field type defaults (#18228) 2023-05-24 06:50:45 +03:00
json_option_alias_test.v json: fix option alias support (#18801) 2023-07-07 22:03:41 +03:00
json_option_none_test.v json: fix option state (#18802) 2023-07-09 08:23:24 +03:00
json_option_struct_test.v
json_option_test.v
json_primitives.v
json_raw_test.v
json_struct_option_test.v
json_test.v
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
}